From 76a1470b29283846b1f69da1c205c265a44a1b22 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 12:26:28 +0000 Subject: [PATCH 01/15] Update .gitlab-ci.yml --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 126e3418..0932def4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,6 +45,7 @@ prepare_node: before_script: - npm install script: + - export - npm run prod artifacts: paths: -- GitLab From c4391c5500b223a6daab2c9e6fb660d2823509fc Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 12:43:52 +0000 Subject: [PATCH 02/15] Only copying dependencies into container --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bfdd92ca..d28227c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,11 @@ RUN sed -i 's/;error_log = log\/php7\/error.log/error_log = \/dev\/stderr/g' /et COPY config/nginx.conf /etc/nginx/nginx.conf COPY config/nginx-default.conf /etc/nginx/conf.d/default.conf RUN sed -i 's/fastcgi_pass phpfpm:9000;/fastcgi_pass localhost:9000;/g' /etc/nginx/conf.d/default.conf -COPY --chown=root:nginx . /html +COPY --chown=root:nginx ./node_modules /html/node_modules +COPY --chown=root:nginx ./vendor /html/vendor +COPY --chown=root:nginx ./public/css /html/public/css +COPY --chown=root:nginx ./public/js /html/public/js +COPY --chown=root:nginx ./public/mix-manifest.json /html/public/mix-manifest.json WORKDIR /html EXPOSE 80 -- GitLab From 2655dadc022368bece1e360e26477255b6e7b3b1 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:07:03 +0000 Subject: [PATCH 03/15] dockerfile cloning copy of source code --- .gitlab-ci.yml | 1 + Dockerfile | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0932def4..8d6c5544 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,6 +78,7 @@ review: variables: HELM_UPGRADE_VALUES_FILE: .gitlab/review-apps-values.yaml ROLLOUT_RESOURCE_TYPE: deployment + AUTO_DEVOPS_BUILD_IMAGE_FORWARDED_CI_VARIABLES: CI_COMMIT_BRANCH,CI_PROJECT_URL environment: name: review/$CI_COMMIT_REF_NAME on_stop: stop_review diff --git a/Dockerfile b/Dockerfile index d28227c5..a3341e92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM alpine:3.11.3 RUN apk add --update \ + git \ nginx \ tzdata \ ca-certificates \ @@ -65,16 +66,18 @@ RUN sed -i 's/;error_log = log\/php7\/error.log/error_log = \/dev\/stderr/g' /et COPY config/nginx.conf /etc/nginx/nginx.conf COPY config/nginx-default.conf /etc/nginx/conf.d/default.conf RUN sed -i 's/fastcgi_pass phpfpm:9000;/fastcgi_pass localhost:9000;/g' /etc/nginx/conf.d/default.conf -COPY --chown=root:nginx ./node_modules /html/node_modules -COPY --chown=root:nginx ./vendor /html/vendor -COPY --chown=root:nginx ./public/css /html/public/css -COPY --chown=root:nginx ./public/js /html/public/js -COPY --chown=root:nginx ./public/mix-manifest.json /html/public/mix-manifest.json + +COPY --chown=root:nginx ./vendor /tmp/vendor +COPY --chown=root:nginx ./public/css /tmp/public/css +COPY --chown=root:nginx ./public/js /tmp/public/js +COPY --chown=root:nginx ./tmp/mix-manifest.json /html/public/mix-manifest.json WORKDIR /html EXPOSE 80 -CMD cp /root/.env .env && \ +CMD mkdir /html && \ + git clone --depth=1 --branch=$CI_COMMIT_BRANCH ${CI_PROJECT_URL}.git /html + cp /root/.env .env && \ sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env && \ if [ "$GITLAB_ENVIRONMENT_NAME" = "production" ]; then sed -i 's/^APP_ENV=.*/APP_ENV=production/g' .env; else sed -i 's/^APP_ENV=.*/APP_ENV=development/g' .env; fi && \ cp database/useragents.sqlite.example database/useragents.sqlite && \ -- GitLab From 80997713b0b9714c3913505b8507abe5979c16c6 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:11:05 +0000 Subject: [PATCH 04/15] fixed typo --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a3341e92..0d791827 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,7 +76,7 @@ WORKDIR /html EXPOSE 80 CMD mkdir /html && \ - git clone --depth=1 --branch=$CI_COMMIT_BRANCH ${CI_PROJECT_URL}.git /html + git clone --depth=1 --branch=$CI_COMMIT_BRANCH ${CI_PROJECT_URL}.git /html && \ cp /root/.env .env && \ sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env && \ if [ "$GITLAB_ENVIRONMENT_NAME" = "production" ]; then sed -i 's/^APP_ENV=.*/APP_ENV=production/g' .env; else sed -i 's/^APP_ENV=.*/APP_ENV=development/g' .env; fi && \ -- GitLab From 087998345da77ac747986d6cbb081e4b2dd51611 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:14:47 +0000 Subject: [PATCH 05/15] fixed typo --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0d791827..4c331459 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,7 +70,7 @@ RUN sed -i 's/fastcgi_pass phpfpm:9000;/fastcgi_pass localhost:9000;/g' /etc/ngi COPY --chown=root:nginx ./vendor /tmp/vendor COPY --chown=root:nginx ./public/css /tmp/public/css COPY --chown=root:nginx ./public/js /tmp/public/js -COPY --chown=root:nginx ./tmp/mix-manifest.json /html/public/mix-manifest.json +COPY --chown=root:nginx ./public/mix-manifest.json /tmp/public/mix-manifest.json WORKDIR /html EXPOSE 80 -- GitLab From c7fd91e658ec1ec446c24d21fd966707a1792645 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:19:23 +0000 Subject: [PATCH 06/15] added rsync --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 4c331459..a0c3191f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM alpine:3.11.3 RUN apk add --update \ git \ + rsync \ nginx \ tzdata \ ca-certificates \ -- GitLab From 098a740f33a23c1429112b5e6d5560fcc5489d94 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:27:00 +0000 Subject: [PATCH 07/15] fixed deployment --- Dockerfile | 2 ++ chart/templates/deployment.yaml | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a0c3191f..1976ed33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,6 +79,8 @@ EXPOSE 80 CMD mkdir /html && \ git clone --depth=1 --branch=$CI_COMMIT_BRANCH ${CI_PROJECT_URL}.git /html && \ cp /root/.env .env && \ + rsync -avz /tmp/public/ /html/public/ + rsync -avz /tmp/vendor/ /html/vendor/ sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env && \ if [ "$GITLAB_ENVIRONMENT_NAME" = "production" ]; then sed -i 's/^APP_ENV=.*/APP_ENV=production/g' .env; else sed -i 's/^APP_ENV=.*/APP_ENV=development/g' .env; fi && \ cp database/useragents.sqlite.example database/useragents.sqlite && \ diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index f287afaf..823a0465 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -143,7 +143,13 @@ spec: # Nginx Container - name: {{ .Chart.Name }}-nginx image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - command: ["nginx"] + command: ["/bin/sh", "-c"] + args: + - mkdir /html && + git clone --depth=1 --branch=$CI_COMMIT_BRANCH ${CI_PROJECT_URL}.git /html && + rsync -avz /tmp/public/ /html/public/ && + rsync -avz /tmp/vendor/ /html/vendor/ && + nginx imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.application.secretName }} envFrom: -- GitLab From f7ab2e054a4f73d2ae3639c32cf3775a0b2dc45a Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:39:04 +0000 Subject: [PATCH 08/15] added rules to skip pipelines --- .gitlab-ci.yml | 25 ++++++++++++++++++++++--- Dockerfile | 4 ++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8d6c5544..4003f477 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,6 +38,15 @@ stages: build: services: + rules: + - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' + when: always + - changes: + - package.json + - webpack.mix.js + - composer.json + - Dockerfile + when: always prepare_node: stage: prepare @@ -57,9 +66,13 @@ prepare_node: key: "node-$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG" paths: - node_modules - only: - - branches - - tags + rules: + - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' + when: always + - changes: + - package.json + - webpack.mix.js + when: always prepare_composer: stage: prepare @@ -73,6 +86,12 @@ prepare_composer: key: "composer-$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG" paths: - vendor + rules: + - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' + when: always + - changes: + - composer.json + when: always review: variables: diff --git a/Dockerfile b/Dockerfile index 1976ed33..f9a5c07a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,8 +79,8 @@ EXPOSE 80 CMD mkdir /html && \ git clone --depth=1 --branch=$CI_COMMIT_BRANCH ${CI_PROJECT_URL}.git /html && \ cp /root/.env .env && \ - rsync -avz /tmp/public/ /html/public/ - rsync -avz /tmp/vendor/ /html/vendor/ + rsync -avz /tmp/public/ /html/public/ && \ + rsync -avz /tmp/vendor/ /html/vendor/ && \ sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env && \ if [ "$GITLAB_ENVIRONMENT_NAME" = "production" ]; then sed -i 's/^APP_ENV=.*/APP_ENV=production/g' .env; else sed -i 's/^APP_ENV=.*/APP_ENV=development/g' .env; fi && \ cp database/useragents.sqlite.example database/useragents.sqlite && \ -- GitLab From 149bc6a8a0034fa7890b09689ef3565883f36915 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:41:22 +0000 Subject: [PATCH 09/15] fixed rules --- .gitlab-ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4003f477..853a86a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,7 +46,6 @@ build: - webpack.mix.js - composer.json - Dockerfile - when: always prepare_node: stage: prepare @@ -68,11 +67,9 @@ prepare_node: - node_modules rules: - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' - when: always - changes: - package.json - webpack.mix.js - when: always prepare_composer: stage: prepare @@ -91,7 +88,6 @@ prepare_composer: when: always - changes: - composer.json - when: always review: variables: -- GitLab From 8d4b931be4a4cff75eeb316cdae034586179229a Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:54:33 +0000 Subject: [PATCH 10/15] fixed rules --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 853a86a8..1ea9c1de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,6 +46,7 @@ build: - webpack.mix.js - composer.json - Dockerfile + - when: never prepare_node: stage: prepare @@ -67,9 +68,11 @@ prepare_node: - node_modules rules: - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' + when: always - changes: - package.json - webpack.mix.js + - when: never prepare_composer: stage: prepare @@ -88,6 +91,7 @@ prepare_composer: when: always - changes: - composer.json + - when: always review: variables: -- GitLab From 2ede4ee4b543af57b146a5ec3f07184a93badd0a Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 13:58:55 +0000 Subject: [PATCH 11/15] only triggering for merge_request_events --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ea9c1de..ef4be43b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,6 +33,10 @@ stages: - integrationtest - cleanup +workflow: + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + .auto-deploy: image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v1.0.6" -- GitLab From 35bed2f932ad4dfa45c41ddf0c5abd45fdb57718 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 14:05:29 +0000 Subject: [PATCH 12/15] changed if rule --- .gitlab-ci.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef4be43b..d0c93ea6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,7 @@ stages: workflow: rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + - if: $CI_COMMIT_BRANCH .auto-deploy: image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v1.0.6" @@ -43,6 +43,7 @@ workflow: build: services: rules: + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' when: always - changes: @@ -50,6 +51,7 @@ build: - webpack.mix.js - composer.json - Dockerfile + when: always - when: never prepare_node: @@ -71,12 +73,13 @@ prepare_node: paths: - node_modules rules: + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' when: always - changes: - package.json - webpack.mix.js - - when: never + when: always prepare_composer: stage: prepare @@ -91,11 +94,12 @@ prepare_composer: paths: - vendor rules: + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' when: always - changes: - composer.json - - when: always + when: always review: variables: -- GitLab From 20879a6262b5fc1a4897c60bd85cf1d61a7b630e Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 14:10:35 +0000 Subject: [PATCH 13/15] fixed if clause --- .gitlab-ci.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0c93ea6..7374be45 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,10 +33,6 @@ stages: - integrationtest - cleanup -workflow: - rules: - - if: $CI_COMMIT_BRANCH - .auto-deploy: image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v1.0.6" @@ -44,9 +40,10 @@ build: services: rules: - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' - - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' + if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' when: always - - changes: + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + changes: - package.json - webpack.mix.js - composer.json @@ -74,12 +71,14 @@ prepare_node: - node_modules rules: - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' - - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' + if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' when: always - - changes: + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + changes: - package.json - webpack.mix.js when: always + - when: never prepare_composer: stage: prepare @@ -95,11 +94,13 @@ prepare_composer: - vendor rules: - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' - - if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' + if: '$CI_COMMIT_BEFORE_SHA == "0000000000000000000000000000000000000000"' when: always - - changes: + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + changes: - composer.json when: always + - when: never review: variables: -- GitLab From 0157558835ec951cc976105af33b7b73ff241a85 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 14:12:12 +0000 Subject: [PATCH 14/15] added workflow rule --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7374be45..2d0ac5db 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,6 +36,10 @@ stages: .auto-deploy: image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v1.0.6" +workflow: + rules: + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + build: services: rules: -- GitLab From b5585360434ea6c914033af519077497aae0b17f Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Mon, 9 Nov 2020 14:18:28 +0000 Subject: [PATCH 15/15] using latest tag --- .gitlab/review-apps-values.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab/review-apps-values.yaml b/.gitlab/review-apps-values.yaml index a8a7331b..7cc42529 100644 --- a/.gitlab/review-apps-values.yaml +++ b/.gitlab/review-apps-values.yaml @@ -1,5 +1,7 @@ postgresql: enabled: false +image: + tag: latest hpa: enabled: false resources: @@ -36,4 +38,4 @@ resourcesRedis: limits: resourcesFetcher: requests: - limits: \ No newline at end of file + limits: -- GitLab