From cc090daa6d214c8d21b913aadf25b4fb501ae72d Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 12:49:13 +0000 Subject: [PATCH 01/19] First test of deploying to the container registry --- .gitlab-ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16d6ce6..0c252b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,4 +8,14 @@ pytest: script: - cd /builds/u5500327/wmgzon - pip install -r requirements.txt - - pytest \ No newline at end of file + - pytest + +deploy: + image: docker:20.10.16 + stage: deploy + services: + - docker:20.10.16-dind + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build -t $CI_REGISTRY/group/project/image:latest . + - docker push $CI_REGISTRY/group/project/image:latest \ No newline at end of file From 50ec369daea8a57d42fab5def3bdb39074a5467c Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 12:55:49 +0000 Subject: [PATCH 02/19] #11 Updated pipeline to pass password via stdin --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c252b3..626c57f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,6 @@ deploy: services: - docker:20.10.16-dind script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin <<< $CI_REGISTRY_PASSWORD - docker build -t $CI_REGISTRY/group/project/image:latest . - docker push $CI_REGISTRY/group/project/image:latest \ No newline at end of file From 2ec07edb7e3a90c1ef05f8d115b90b9b9c81d3d1 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 12:58:44 +0000 Subject: [PATCH 03/19] #11 Updated pipeline to pass token via stdin --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 626c57f..bc86ef3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,7 @@ deploy: services: - docker:20.10.16-dind script: - - docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin <<< $CI_REGISTRY_PASSWORD + - docker login $CI_REGISTRY -u $CI_DEPLOY_USER --password-stdin <<<$CI_DEPLOY_PASSWORD + # - docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin <<< $CI_REGISTRY_PASSWORD - docker build -t $CI_REGISTRY/group/project/image:latest . - docker push $CI_REGISTRY/group/project/image:latest \ No newline at end of file From 31215585da94deaf54a316f196dea2c5c11c312d Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:04:04 +0000 Subject: [PATCH 04/19] #11 Trying difference permutations to connect to the registry --- .gitlab-ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bc86ef3..213b531 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,6 @@ deploy: services: - docker:20.10.16-dind script: - - docker login $CI_REGISTRY -u $CI_DEPLOY_USER --password-stdin <<<$CI_DEPLOY_PASSWORD - # - docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin <<< $CI_REGISTRY_PASSWORD - - docker build -t $CI_REGISTRY/group/project/image:latest . - - docker push $CI_REGISTRY/group/project/image:latest \ No newline at end of file + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker pull $CI_REGISTRY/group/other-project:latest + - docker run $CI_REGISTRY/group/other-project:latest \ No newline at end of file From 737e0e7a2268ddeacea86ab88d94ba86bdcfe6fe Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:07:54 +0000 Subject: [PATCH 05/19] #11 Added variables to allow for connection to registry --- .gitlab-ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 213b531..e84e2ed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,11 +11,16 @@ pytest: - pytest deploy: - image: docker:20.10.16 + variables: + DOCKER_HOST: tcp://docker:2375/ + DOCKER_DRIVER: overlay2 + image: docker:stable stage: deploy services: - - docker:20.10.16-dind + - docker:dind script: - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker pull $CI_REGISTRY/group/other-project:latest - - docker run $CI_REGISTRY/group/other-project:latest \ No newline at end of file + - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA . + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest + - docker push $CI_REGISTRY_IMAGE:latest \ No newline at end of file From 76f1a5d9921529a71cdbf061bd3f7df23144c695 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:12:56 +0000 Subject: [PATCH 06/19] #11 Removed : from pipeline as it caused failure --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e84e2ed..2e56df1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,12 +3,12 @@ variables: ENVIRON: "test" FILESTORE: "static/assets/img/products/" -pytest: - stage: test - script: - - cd /builds/u5500327/wmgzon - - pip install -r requirements.txt - - pytest +# pytest: +# stage: test +# script: +# - cd /builds/u5500327/wmgzon +# - pip install -r requirements.txt +# - pytest deploy: variables: @@ -19,7 +19,7 @@ deploy: services: - docker:dind script: - - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA . + - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest From 61e845c5b1463f26a9e6b58b70c88ed400c51298 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:15:22 +0000 Subject: [PATCH 07/19] #11 Moved env vars into correct location for pipeline --- .gitlab-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e56df1..6f438bf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,8 @@ variables: APPSECRET: "test" ENVIRON: "test" FILESTORE: "static/assets/img/products/" + DOCKER_HOST: tcp://docker:2375/ + DOCKER_DRIVER: overlay2 # pytest: # stage: test @@ -11,9 +13,6 @@ variables: # - pytest deploy: - variables: - DOCKER_HOST: tcp://docker:2375/ - DOCKER_DRIVER: overlay2 image: docker:stable stage: deploy services: From 61f2b86746a67ea9a974b18e29fe9a1755c0be18 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:18:41 +0000 Subject: [PATCH 08/19] #11 Added alias to registry to allow for connection. --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f438bf..b4ce4ee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,10 +13,11 @@ variables: # - pytest deploy: - image: docker:stable stage: deploy - services: - - docker:dind + image: $CI_REGISTRY/group/project/docker:20.10.16 + services: + - name: $CI_REGISTRY/group/project/docker:20.10.16-dind + alias: docker script: - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY From 1420a3115fb410a54b0e0228d287c1f02f82ff93 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:19:23 +0000 Subject: [PATCH 09/19] #11 corrected indentaiton on ci file --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b4ce4ee..286b265 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,9 +15,9 @@ variables: deploy: stage: deploy image: $CI_REGISTRY/group/project/docker:20.10.16 - services: - - name: $CI_REGISTRY/group/project/docker:20.10.16-dind - alias: docker + services: + - name: $CI_REGISTRY/group/project/docker:20.10.16-dind + alias: docker script: - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY From 8f7842eb0a657d6b6cb2b5ab076216698f99499f Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:20:29 +0000 Subject: [PATCH 10/19] #11 Missing - added --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 286b265..60afa04 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ deploy: image: $CI_REGISTRY/group/project/docker:20.10.16 services: - name: $CI_REGISTRY/group/project/docker:20.10.16-dind - alias: docker + - alias: docker script: - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY From 402457859144310d9b832f2b62a643f53c0d6fa1 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:23:14 +0000 Subject: [PATCH 11/19] #11 Fixed lint warnings on pipeline --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 60afa04..65e3950 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ deploy: image: $CI_REGISTRY/group/project/docker:20.10.16 services: - name: $CI_REGISTRY/group/project/docker:20.10.16-dind - - alias: docker + alias: docker script: - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY From b340beab3cb392c4893d19711a45f27bd636e156 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:25:45 +0000 Subject: [PATCH 12/19] #11 Corrected container name --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 65e3950..b37ec6d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,9 +14,9 @@ variables: deploy: stage: deploy - image: $CI_REGISTRY/group/project/docker:20.10.16 + image: docker:20.10.16 services: - - name: $CI_REGISTRY/group/project/docker:20.10.16-dind + - name: docker:20.10.16-dind alias: docker script: - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . From 3c1eaf048cbc3618effea015f130fadc7e2ab2c3 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:28:30 +0000 Subject: [PATCH 13/19] #11 Moved login to before any registry actions --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b37ec6d..83abf36 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,8 +19,8 @@ deploy: - name: docker:20.10.16-dind alias: docker script: - - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest - docker push $CI_REGISTRY_IMAGE:latest \ No newline at end of file From e4d8cb2defef92cb9d416561c1d0682b7e538ba9 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:31:04 +0000 Subject: [PATCH 14/19] #11 Changed container name --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 83abf36..7768ccb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,9 +14,9 @@ variables: deploy: stage: deploy - image: docker:20.10.16 + image: docker:latest services: - - name: docker:20.10.16-dind + - name: docker:latest-dind alias: docker script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY From 7551da4aaae8b0c7e770f7756ed6f25855bd4d8a Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 13:32:12 +0000 Subject: [PATCH 15/19] #11 Changed container name --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7768ccb..75d2f72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ deploy: stage: deploy image: docker:latest services: - - name: docker:latest-dind + - name: docker:dind alias: docker script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY From e5308ecda25d9a700273d865cc2c8f78b0266ce7 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 14:02:07 +0000 Subject: [PATCH 16/19] #11 Created a separate runner withappropriate container for running --- .gitlab-ci.yml | 20 ++++++++++++-------- cicd/docker-compose.yml | 11 +++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 75d2f72..77cc01a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,18 +5,22 @@ variables: DOCKER_HOST: tcp://docker:2375/ DOCKER_DRIVER: overlay2 -# pytest: -# stage: test -# script: -# - cd /builds/u5500327/wmgzon -# - pip install -r requirements.txt -# - pytest +pytest: + stage: test + tags: + - python + script: + - cd /builds/u5500327/wmgzon + - pip install -r requirements.txt + - pytest deploy: stage: deploy - image: docker:latest + tags: + - docker + image: docker:20.10.16 services: - - name: docker:dind + - name: docker:20.10.16-dind alias: docker script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY diff --git a/cicd/docker-compose.yml b/cicd/docker-compose.yml index 34f82de..c16f0ed 100644 --- a/cicd/docker-compose.yml +++ b/cicd/docker-compose.yml @@ -1,8 +1,15 @@ version: '3.8' services: - gitlab-runner: + gitlab-runner-python: image: gitlab/gitlab-runner:latest volumes: - - ./runner-data:/etc/gitlab-runner + - ./runner-data-python:/etc/gitlab-runner + - /var/run/docker.sock:/var/run/docker.sock + restart: unless-stopped + + gitlab-runner-docker: + image: gitlab/gitlab-runner:latest + volumes: + - ./runner-data-docker:/etc/gitlab-runner - /var/run/docker.sock:/var/run/docker.sock restart: unless-stopped \ No newline at end of file From 5776bcb73f40cffd7eac76bf082a0f6668e82296 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 14:23:39 +0000 Subject: [PATCH 17/19] #11 Removed unecessary env vars form pipeline --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77cc01a..668c21f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,8 +2,6 @@ variables: APPSECRET: "test" ENVIRON: "test" FILESTORE: "static/assets/img/products/" - DOCKER_HOST: tcp://docker:2375/ - DOCKER_DRIVER: overlay2 pytest: stage: test @@ -24,7 +22,7 @@ deploy: alias: docker script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build -t $CI_REGISTRY_IMAGE$CI_COMMIT_SHORT_SHA . + - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA . - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest - docker push $CI_REGISTRY_IMAGE:latest \ No newline at end of file From 22833ec7adb65ede5389f8ff4a08b18323a989f0 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 14:27:52 +0000 Subject: [PATCH 18/19] #11 Those were actually important XD --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 668c21f..bb9326a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,9 @@ variables: APPSECRET: "test" ENVIRON: "test" FILESTORE: "static/assets/img/products/" + DOCKER_HOST: tcp://docker:2375/ + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" pytest: stage: test From 164e4aa2136796f46dfd406b45c12c9713561d8f Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 16 Feb 2024 15:03:46 +0000 Subject: [PATCH 19/19] #11 Changed pipeline to only run on master branch --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb9326a..ade65eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,4 +28,6 @@ deploy: - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA . - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest - - docker push $CI_REGISTRY_IMAGE:latest \ No newline at end of file + - docker push $CI_REGISTRY_IMAGE:latest + only: + - master \ No newline at end of file