Loading src/context/.gitlab-ci.yml +49 −44 Original line number Diff line number Diff line # build, tag and push the Docker image to the gitlab registry build context: variables: IMAGE_NAME: 'context' # name of the microservice IMAGE_NAME_TEST: 'context-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) # build the Docker image build context: stage: build before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/ rules: - changes: - src/$IMAGE_NAME/** - .gitlab-ci.yml # tags the Docker image tag context: stage: build script: - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" rules: - changes: - src/$IMAGE_NAME/** - .gitlab-ci.yml # push the Docker image to the gitlab Docker registry push context: stage: build before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile - src/$IMAGE_NAME/** - .gitlab-ci.yml # test if the Docker image can be pulled from the gitlab registry test context pull: variables: IMAGE_NAME: 'context' # name of the microservice IMAGE_NAME_TEST: 'context-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: test needs: - build context - push context before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile - src/$IMAGE_NAME/** - .gitlab-ci.yml # test if the Docker image can be executed test context run: variables: IMAGE_NAME: 'context' # name of the microservice IMAGE_NAME_TEST: 'context-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: test needs: - build context Loading @@ -53,16 +59,18 @@ test context run: - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi script: - docker run -d -p 1010:1010 --name context --network=teraflowbridge --rm "$IMAGE_NAME:$IMAGE_TAG" - docker ps - docker ps > deploy_test_report.txt after_script: - docker stop context rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile - src/$IMAGE_NAME/** - .gitlab-ci.yml artifacts: when: always paths: - deploy_test_report.txt expire_in: 1 day # apply unit test to the context component test context pytest: Loading @@ -73,10 +81,7 @@ test context pytest: - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/ > pytest_report.txt rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile - src/$IMAGE_NAME/** - .gitlab-ci.yml artifacts: when: always Loading @@ -85,14 +90,14 @@ test context pytest: expire_in: 1 day # Deployment of the monitoring service in Kubernetes Cluster #deploy context: # stage: deploy # needs: # - build context # - test context run # script: # - kubectl version # - kubectl get all # - kubectl apply -f "manifests/contextservice.yaml" # - kubectl get all # when: manual deploy context: stage: deploy needs: - build context - test context run script: - kubectl version - kubectl get all - kubectl apply -f "manifests/contextservice.yaml" - kubectl get all when: manual Loading
src/context/.gitlab-ci.yml +49 −44 Original line number Diff line number Diff line # build, tag and push the Docker image to the gitlab registry build context: variables: IMAGE_NAME: 'context' # name of the microservice IMAGE_NAME_TEST: 'context-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) # build the Docker image build context: stage: build before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/ rules: - changes: - src/$IMAGE_NAME/** - .gitlab-ci.yml # tags the Docker image tag context: stage: build script: - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" rules: - changes: - src/$IMAGE_NAME/** - .gitlab-ci.yml # push the Docker image to the gitlab Docker registry push context: stage: build before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile - src/$IMAGE_NAME/** - .gitlab-ci.yml # test if the Docker image can be pulled from the gitlab registry test context pull: variables: IMAGE_NAME: 'context' # name of the microservice IMAGE_NAME_TEST: 'context-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: test needs: - build context - push context before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile - src/$IMAGE_NAME/** - .gitlab-ci.yml # test if the Docker image can be executed test context run: variables: IMAGE_NAME: 'context' # name of the microservice IMAGE_NAME_TEST: 'context-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: test needs: - build context Loading @@ -53,16 +59,18 @@ test context run: - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi script: - docker run -d -p 1010:1010 --name context --network=teraflowbridge --rm "$IMAGE_NAME:$IMAGE_TAG" - docker ps - docker ps > deploy_test_report.txt after_script: - docker stop context rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile - src/$IMAGE_NAME/** - .gitlab-ci.yml artifacts: when: always paths: - deploy_test_report.txt expire_in: 1 day # apply unit test to the context component test context pytest: Loading @@ -73,10 +81,7 @@ test context pytest: - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/ > pytest_report.txt rules: - changes: - src/$IMAGE_NAME/*.{py,in,yml} - src/$IMAGE_NAME/Dockerfile - src/$IMAGE_NAME/tests/*.py - src/$IMAGE_NAME/tests/Dockerfile - src/$IMAGE_NAME/** - .gitlab-ci.yml artifacts: when: always Loading @@ -85,14 +90,14 @@ test context pytest: expire_in: 1 day # Deployment of the monitoring service in Kubernetes Cluster #deploy context: # stage: deploy # needs: # - build context # - test context run # script: # - kubectl version # - kubectl get all # - kubectl apply -f "manifests/contextservice.yaml" # - kubectl get all # when: manual deploy context: stage: deploy needs: - build context - test context run script: - kubectl version - kubectl get all - kubectl apply -f "manifests/contextservice.yaml" - kubectl get all when: manual