From fc38c747aa61f87eb4ffe426a418b88a126a8600 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 17:54:39 +0200 Subject: [PATCH 01/16] check if install also works and is faster than update --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0a6e37..d9bf512 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,7 @@ lint_fe: image: johnpapa/angular-cli script: - cd ./frontend - - npm update + - npm install - npm run -- ng lint extends: - .lint From d04930fd8e6fbf5a61d04d186c5acc92c7610834 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 18:07:01 +0200 Subject: [PATCH 02/16] update --- backend/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/.gitignore b/backend/.gitignore index bca7cc3..2f19d79 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -7,3 +7,4 @@ media/feed-icons *.sqlite3 waecm-2021-group-04.egg-info app_be/migrations +/dist From 1d1dd227fae29afe6b3843a24dcbb1aa3c602762 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 18:41:14 +0200 Subject: [PATCH 03/16] build backend in CI use this build package in docker-compose; --- backend/Dockerfile | 32 ++++++++++++++++++-------------- backend/setup.py | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 5a43e77..c7f900e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -2,20 +2,24 @@ FROM python:3.8-slim ENV PYTHONUNBUFFERED 1 ENV PATH="/opt/venv/bin:$PATH" -RUN apt-get update; \ - apt-get install -y build-essential gcc; \ - python -m venv /opt/venv; \ - python -m pip install --upgrade pip; \ - mkdir /code; - -WORKDIR /code - -COPY setup.py /code/ -COPY requirements.txt /code/ - -RUN pip install -r requirements.txt +# will be build in a different stage in CI +#RUN apt-get update; \ +# apt-get install -y build-essential gcc; \ +# python -m venv /opt/venv; \ +# python -m pip install --upgrade pip; \ +# mkdir /code; +# +#WORKDIR /code +# +#COPY setup.py /code/ +#COPY requirements.txt /code/ +# +#RUN pip install -r requirements.txt +# install and use built artifact COPY . /code/ +WORKDIR /code +RUN pip install ./dist/waecm* -RUN chmod 777 scripts/entrypoint.sh -ENTRYPOINT ["scripts/entrypoint.sh"] +RUN chmod 777 ./scripts/entrypoint.sh +ENTRYPOINT ["./scripts/entrypoint.sh"] diff --git a/backend/setup.py b/backend/setup.py index ea14854..4c693f4 100644 --- a/backend/setup.py +++ b/backend/setup.py @@ -5,7 +5,7 @@ from setuptools import find_packages, setup os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup(name='waecm-2021-group-04', - version='0.0.0', + version='3', packages=find_packages(), include_package_data=True, install_requires=[ From 085e9e6e2609e4aab2a7776d54ce02445ffbfc20 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 18:42:33 +0200 Subject: [PATCH 04/16] speedup process with an image which has angular cli installed --- frontend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index e7389d9..654aa2e 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,6 +1,6 @@ # Stage 1 -FROM node:alpine +FROM johnpapa/angular-cli WORKDIR /app From b2789674177b7f86ad57c8ab4202ad3ef691f5d5 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:08:50 +0200 Subject: [PATCH 05/16] swtich to docker build --- .gitlab-ci.yml | 92 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d9bf512..2c63ca8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,19 +2,13 @@ stages: - build - lint - test - - compose-build - - compose-push + - docker-build + - docker-push -.lint: - stage: lint -.build: - stage: build -.test: - stage: test -.compose-build: - stage: compose-build -.compose-push: - stage: compose-push +.python-image: + image: python:3.8-slim +.angular-image: + image: johnpapa/angular-cli ######## # BUILD @@ -26,9 +20,10 @@ stages: # - echo '' # extends: # - .build +.build: + stage: build build_be: - image: python:3.8-slim before_script: - apt-get update - apt-get install -y build-essential gcc @@ -41,19 +36,24 @@ build_be: untracked: true extends: - .build + - .python-image ######## # LINT ################################################################# +.lint: + stage: lint lint_fe: - image: johnpapa/angular-cli script: - cd ./frontend - npm install - - npm run -- ng lint + - ng lint extends: - .lint + - .angular-image + artifacts: + untracked: true # needs: # - build_fe @@ -68,45 +68,73 @@ lint_fe: ######## # TEST ################################################################# +.test: + stage: test test_fe: script: - - echo '' + - ng test extends: - .test + - .angular-image needs: - lint_fe -test_be: +#test_be: +# script: +# - cd ./backend +# - ls -l +# extends: +# - .test +# needs: +# - build_be + +######## +# DOCKER-BUILD +################################################################# +.docker-build: + stage: docker-build + +.docker-setup: + before_script: + - echo $DOCKER_PW | docker login -u $DOCKER_USER --password-stdin + +docker-build-fe: script: - - cd ./backend - - ls -l + - echo "" extends: - - .test + - .docker-build + - .docker-setup + needs: + - test_fe + +docker-build-be: + script: + - echo "" + extends: + - .docker-build + - .docker-setup needs: - build_be ######## -# COMPOSE-BUILD +# DOCKER-PUSH ################################################################# +.docker-push: + stage: docker-push -compose-build: +docker-push-fe: script: - echo '' extends: - - .compose-build + - .docker-push needs: - - test_be - - test_fe + - docker-build-fe -######## -# COMPOSE-PUSH -################################################################# - -compose-push: +docker-push-be: script: - echo '' extends: - - .compose-push + - .docker-push needs: - - compose-build + - docker-build-be From 41aab51c7b252165069662c7a0ce7dceaf53bf08 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:17:36 +0200 Subject: [PATCH 06/16] swtich back to docker-compose --- .gitlab-ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c63ca8..f4f7804 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,7 @@ +variables: + DOCKER_USER: pfingstfrosch + ASSIGNMENT: waecm-2021-group-04-bsp-3 + stages: - build - lint @@ -98,10 +102,13 @@ test_fe: .docker-setup: before_script: - echo $DOCKER_PW | docker login -u $DOCKER_USER --password-stdin + artifacts: + untracked: true docker-build-fe: script: - - echo "" + - docker-compose build waecm_g4_fe + - docker save -o waecm_g4_fe ${DOCKER_USER}/${ASSIGNMENT}-fe extends: - .docker-build - .docker-setup @@ -110,7 +117,8 @@ docker-build-fe: docker-build-be: script: - - echo "" + - docker-compose build waecm_g4_be + - docker save -o waecm_g4_be ${DOCKER_USER}/${ASSIGNMENT}-be extends: - .docker-build - .docker-setup From ab2f137b32cde49dd26a09c59db9fcdbe50aba68 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:19:36 +0200 Subject: [PATCH 07/16] swtich back to docker-compose but split up the different images; --- .gitlab-ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f4f7804..978f7a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -133,16 +133,20 @@ docker-build-be: docker-push-fe: script: - - echo '' + - docker image load --input waecm_g4_fe + - docker-compose push waecm_g4_fe extends: - .docker-push + - .docker-setup needs: - docker-build-fe docker-push-be: script: - - echo '' + - docker image load --input waecm_g4_be + - docker-compose push waecm_g4_be extends: - .docker-push + - .docker-setup needs: - docker-build-be From ea202da8a3d10654cf19546a1bf54397056b1c8a Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:31:46 +0200 Subject: [PATCH 08/16] use docker tagged runner --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 978f7a3..2607c34 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -104,6 +104,8 @@ test_fe: - echo $DOCKER_PW | docker login -u $DOCKER_USER --password-stdin artifacts: untracked: true + tags: + - docker docker-build-fe: script: From d094ab5cd887a192283711553704f8d422dfe460 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:32:31 +0200 Subject: [PATCH 09/16] fix path --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2607c34..8d03257 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,6 +77,7 @@ lint_fe: test_fe: script: + - cd ./frontend - ng test extends: - .test From a2bac88db1e1419a4e036f54552301e8585146e1 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:35:16 +0200 Subject: [PATCH 10/16] use image containing docker binaries --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8d03257..c008f14 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -101,6 +101,7 @@ test_fe: stage: docker-build .docker-setup: + image: gitlab/dind before_script: - echo $DOCKER_PW | docker login -u $DOCKER_USER --password-stdin artifacts: From 7866f4152fb8bd3e1564d2c63bfc55be897180ea Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:35:59 +0200 Subject: [PATCH 11/16] use image containing docker binaries --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c008f14..7e2e088 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -102,6 +102,8 @@ test_fe: .docker-setup: image: gitlab/dind + services: + - docker:dind before_script: - echo $DOCKER_PW | docker login -u $DOCKER_USER --password-stdin artifacts: From 6d80cf94e34ba7776470fefafea84b0d0b1f4cc2 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:46:14 +0200 Subject: [PATCH 12/16] retry --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e2e088..f7efbeb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -105,7 +105,7 @@ test_fe: services: - docker:dind before_script: - - echo $DOCKER_PW | docker login -u $DOCKER_USER --password-stdin + - echo "$DOCKER_PW" | docker login --username $DOCKER_USER --password-stdin artifacts: untracked: true tags: From bb5f40c93a62415180dc51db383b6221c709b502 Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:48:38 +0200 Subject: [PATCH 13/16] use npm update instead of npm install --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f7efbeb..3ca48df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,7 +51,7 @@ build_be: lint_fe: script: - cd ./frontend - - npm install + - npm update - ng lint extends: - .lint @@ -78,6 +78,7 @@ lint_fe: test_fe: script: - cd ./frontend + - npm update - ng test extends: - .test From 86db2e63f79fd67a2942da7b11f1bf6c8a1cd4ac Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:49:50 +0200 Subject: [PATCH 14/16] --password-stdin does not work --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3ca48df..2d937de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -106,7 +106,7 @@ test_fe: services: - docker:dind before_script: - - echo "$DOCKER_PW" | docker login --username $DOCKER_USER --password-stdin + - docker login -u $DOCKER_USER -p $DOCKER_PW artifacts: untracked: true tags: From 9779d9f463e60b6977e8198d12c624a5612b729a Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:52:55 +0200 Subject: [PATCH 15/16] added ci info [skip ci] --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 244f88a..9267686 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,7 @@ The docker images are available at: * sha256 digest: 2d6526c871285f81dee714f41c41750e6e9c4e124cdc78f69ecd17036f620399 * [waecm-2021-group-04-bsp2-be](https://hub.docker.com/r/pfingstfrosch/waecm-2021-group-04-bsp-2-be) * sha256 digest: fe0b490a7ad5546371a8a709c9e4f80985326c9a27dddfeef6179f89affc9105 + +## CI +Look at git-lab project https://gitlab.com/Pfingstfrosch/waecm-g4-CI for CI execution. +This repository is mirrored to the CI repo, where the pipeline is executed. \ No newline at end of file From 5320763ca419eb98ed8a58ad34f85789d6068ebf Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Tue, 11 May 2021 19:59:32 +0200 Subject: [PATCH 16/16] try another docker image --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d937de..83c399f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -102,7 +102,7 @@ test_fe: stage: docker-build .docker-setup: - image: gitlab/dind + image: docker:latest services: - docker:dind before_script: