From 18528656dbfa88e1eb6801285482292c71aadfe5 Mon Sep 17 00:00:00 2001 From: Karl Muller Date: Mon, 17 Feb 2025 08:31:26 +0000 Subject: [PATCH] feat: :sparkles: add cicd + Dockerfile --- .dockerignore | 11 +++++++++ .gitlab-ci.yml | 19 ++++++++++++++ Dockerfile | 22 +++++++++++++++++ manifest.yaml | 52 +++++++++++++++++++++++++++++++++++++++ production-resources.yaml | 11 +++++++++ 5 files changed, 115 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100644 manifest.yaml create mode 100644 production-resources.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a680f41 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git/ +.gitlab/ +.gitlab-ci.yml +*.md +.vscode/ +auth.json +Dockerfile +manifest.yaml +node_modules/ +production-resources.yaml + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..77b5d46 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,19 @@ +include: + - project: "ldc-web/shared-ci" + ref: "main" + file: "security/security.yml" + - project: "ldc-web/shared-ci" + ref: "main" + file: "build/docker-multistage.yml" + - project: "ldc-web/shared-ci" + ref: "main" + file: "test/test.yml" + - project: "ldc-web/shared-ci" + ref: "main" + file: "deploy/deploy.yml" + +stages: + - security + - build + - test + - deploy diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9634fcb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM composer:2.8 AS vendor + +COPY composer.json composer.json +COPY composer.lock composer.lock + +RUN composer install \ + --ignore-platform-reqs \ + --no-interaction \ + --no-plugins \ + --no-scripts \ + --no-dev \ + --prefer-dist + + +FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/ldcweb-production-7.3:latest + +ARG USER=www-data + +COPY --chown=${USER}:${USER} . /app/srcs +COPY --from=vendor --chown=${USER}:${USER} /app/vendor/ /app/srcs/vendor/ + +USER ${USER} diff --git a/manifest.yaml b/manifest.yaml new file mode 100644 index 0000000..4478c4d --- /dev/null +++ b/manifest.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ${CI_PROJECT_PATH_SLUG}-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: ${CI_PROJECT_PATH_SLUG}-app + template: + metadata: + labels: + app: ${CI_PROJECT_PATH_SLUG}-app + spec: + containers: + - name: ${CI_PROJECT_PATH_SLUG}-container + image: $IMAGE_TAG + imagePullSecrets: + - name: docker-registry-credentials + securityContext: + runAsUser: 33 + runAsGroup: 33 + fsGroup: 33 + fsGroupChangePolicy: "OnRootMismatch" +--- +apiVersion: v1 +kind: Service +metadata: + name: ${CI_PROJECT_PATH_SLUG}-service +spec: + selector: + app: ${CI_PROJECT_PATH_SLUG}-app + ports: + - port: 80 + targetPort: 443 +--- +apiVersion: traefik.io/v1alpha1 +kind: IngressRoute +metadata: + name: ${CI_PROJECT_PATH_SLUG}-ingress-route +spec: + entryPoints: + - web + - websecure + routes: + - match: Host(`${APP_DOMAIN}`) + kind: Rule + services: + - name: ${CI_PROJECT_PATH_SLUG}-service + port: 80 + tls: + secretName: ${CRT_TLS_NAME} diff --git a/production-resources.yaml b/production-resources.yaml new file mode 100644 index 0000000..721e5d2 --- /dev/null +++ b/production-resources.yaml @@ -0,0 +1,11 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: $APP_DOMAIN +spec: + dnsNames: + - $APP_DOMAIN + secretName: $APP_DOMAIN + issuerRef: + name: $APP_CERT_ISSUER + kind: ClusterIssuer