diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..2c562ae --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +image: docker:latest + +services: + - docker:dind + +before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + +build-master: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE" . + - docker push "$CI_REGISTRY_IMAGE" + only: + - master + +build: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + except: + - master diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c814681 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +ARG VERSION="latest" +FROM "jcabillot/phpapache:${VERSION}" +LABEL maintainer="Julien Cabillot " + +COPY "root" "/var/www/html" diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..a5c8450 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,38 @@ +pipeline { + environment { + registry = 'https://registry.hub.docker.com' + registryCredential = 'dockerhub_jcabillot' + dockerImage = 'jcabillot/cv' + } + + agent any + + triggers { + cron('@midnight') + } + + stages { + stage('Clone repository') { + steps{ + checkout scm + } + } + + stage('Build image') { + steps{ + sh 'docker build --force-rm=true --no-cache=true --pull -t ${dockerImage} .' + } + } + + stage('Deploy Image') { + steps{ + script { + withCredentials([usernamePassword(credentialsId: 'dockerhub_jcabillot', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) { + sh 'docker login --username ${DOCKER_USER} --password ${DOCKER_PASS}' + sh 'docker push ${dockerImage}' + } + } + } + } + } +} diff --git a/kustomize/depl.yml b/kustomize/depl.yml new file mode 100644 index 0000000..1b07287 --- /dev/null +++ b/kustomize/depl.yml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: "cv" + labels: + app: "front" +spec: + template: + metadata: + name: "front-apache" + labels: + owner: "jcabillot" + app: "front" + spec: + automountServiceAccountToken: false + containers: + - name: "front-apache" + image: "jcabillot/cv" + ports: + - name: "http" + containerPort: 8080 + protocol: "TCP" + livenessProbe: + httpGet: + path: "/" + port: "http" + readinessProbe: + httpGet: + path: "/" + port: "http" + + replicas: 1 + selector: + matchLabels: + app: "front" diff --git a/kustomize/ingress.yml b/kustomize/ingress.yml new file mode 100644 index 0000000..a9d7b29 --- /dev/null +++ b/kustomize/ingress.yml @@ -0,0 +1,25 @@ +--- +#apiVersion: networking.k8s.io/v1 +#kind: Ingress +#metadata: +# name: "cv" +# annotations: +# kubernetes.io/ingress.class: "traefik" +# traefik.ingress.kubernetes.io/router.entrypoints: "web,websecure" +# cert-manager.io/cluster-issuer: "letsencrypt-prod" +#spec: +# tls: +# - hosts: +# - "cv.opti.cabillot.eu" +# secretName: "cvcabilloteu-tls" +# rules: +# - host: "cv.opti.cabillot.eu" +# http: +# paths: +# - path: "/" +# pathType: "Prefix" +# backend: +# service: +# name: "cv" +# port: +# name: "http" diff --git a/kustomize/ingressroute.yml b/kustomize/ingressroute.yml new file mode 100644 index 0000000..bda3b64 --- /dev/null +++ b/kustomize/ingressroute.yml @@ -0,0 +1,50 @@ +--- +# TODO: Named port for service +# but currently unsupported on my k3s cluster https://github.com/traefik/traefik/pull/7668 +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: "cv-websecure" +spec: + entryPoints: + - "websecure" + routes: + - kind: Rule + match: Host(`cv.opti.cabillot.eu`) + middlewares: [] + priority: 10 + services: + - kind: Service + name: "cv" + port: 80 + tls: + secretName: "cvcabilloteu-tls" +--- +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: "cv-web" +spec: + entryPoints: + - "web" + routes: + - match: Host(`cv.opti.cabillot.eu`) + kind: Rule + priority: 10 + services: + # in this IngressRoute the service will be never called + # because of the redirect middleware BUT DO NOT REMOVE ! + - kind: Service + name: "cv" + port: 80 + middlewares: + - name: "httpsredirect" +--- +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: "httpsredirect" +spec: + redirectScheme: + scheme: https + permanent: true diff --git a/kustomize/kustomization.yaml b/kustomize/kustomization.yaml new file mode 100644 index 0000000..f2d2b82 --- /dev/null +++ b/kustomize/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- depl.yml +- ingress.yml +- ingressroute.yml +- svc.yml diff --git a/kustomize/svc.yml b/kustomize/svc.yml new file mode 100644 index 0000000..db03120 --- /dev/null +++ b/kustomize/svc.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: 'cv' +spec: + type: "ClusterIP" + ports: + - name: "http" + port: 80 + protocol: "TCP" + targetPort: "http" + selector: + app: "front" diff --git a/root/cabillot_julien_cv.pdf b/root/cabillot_julien_cv.pdf new file mode 100644 index 0000000..f84bac7 Binary files /dev/null and b/root/cabillot_julien_cv.pdf differ diff --git a/root/index.html b/root/index.html new file mode 100644 index 0000000..6a6ef57 --- /dev/null +++ b/root/index.html @@ -0,0 +1,9 @@ + + + Redirection vers mon CV + + + + Si votre navigateur ne vous redirige pas automatiquement : mon CV + +