Update pipeline (DRY)

Apply DRY principle by utilizing `extends` and `anchors`
This commit is contained in:
Santiago Lo Coco 2023-11-03 17:08:48 -03:00
parent 23576a99cd
commit fe3edc9288
1 changed files with 206 additions and 370 deletions

View File

@ -7,11 +7,14 @@ variables:
default:
retry:
max: 2
max: 1
when:
- runner_system_failure
- script_failure
- api_failure
before_script:
- export $(cat context.env | xargs)
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
stages:
- prep
@ -24,179 +27,123 @@ preparation:
stage: prep
tags:
- dev
before_script: []
script:
- export BUILD_ID=$(date +%Y%m%d%H%M)
- echo "BUILD_ID=${BUILD_ID}" > context.env
- echo "FLIGHTS_INFO_PROD_IMAGE_NAME=${IMAGE_BASE}/flights-information:prod-${BUILD_ID}" >> context.env
- echo "FLIGHTS_INFO_TEST_IMAGE_NAME=${IMAGE_BASE}/flights-information:test-${BUILD_ID}" >> context.env
- echo "GATEWAY_PROD_IMAGE_NAME=${IMAGE_BASE}/gateway:prod-${BUILD_ID}" >> context.env
- echo "GATEWAY_TEST_IMAGE_NAME=${IMAGE_BASE}/gateway:test-${BUILD_ID}" >> context.env
- echo "USER_MANAGER_PROD_IMAGE_NAME=${IMAGE_BASE}/user-manager:prod-${BUILD_ID}" >> context.env
- echo "USER_MANAGER_TEST_IMAGE_NAME=${IMAGE_BASE}/user-manager:test-${BUILD_ID}" >> context.env
- echo "SUBSCRIPTION_PROD_IMAGE_NAME=${IMAGE_BASE}/subs-manager:prod-${BUILD_ID}" >> context.env
- echo "SUBSCRIPTION_TEST_IMAGE_NAME=${IMAGE_BASE}/subs-manager:test-${BUILD_ID}" >> context.env
- echo "SCREEN_CLIENT_PROD_IMAGE_NAME=${IMAGE_BASE}/screens-client:prod-${BUILD_ID}" >> context.env
- echo "SCREEN_CLIENT_TEST_IMAGE_NAME=${IMAGE_BASE}/screens-client:test-${BUILD_ID}" >> context.env
- echo "BROWSER_CLIENT_PROD_IMAGE_NAME=${IMAGE_BASE}/browser-client:prod-${BUILD_ID}" >> context.env
- echo "BROWSER_CLIENT_TEST_IMAGE_NAME=${IMAGE_BASE}/browser-client:test-${BUILD_ID}" >> context.env
- echo "ELK_SETUP_PROD_IMAGE_NAME=${IMAGE_BASE}/elk-setup:prod" >> context.env
- echo "ELASTIC_PROD_IMAGE_NAME=${IMAGE_BASE}/elasticsearch:prod" >> context.env
- echo "HEARTBEAT_PROD_IMAGE_NAME=${IMAGE_BASE}/heartbeat:prod" >> context.env
- echo "CURATOR_PROD_IMAGE_NAME=${IMAGE_BASE}/curator:prod" >> context.env
- echo "KIBANA_PROD_IMAGE_NAME=${IMAGE_BASE}/kibana:prod" >> context.env
- echo "LOGSTASH_PROD_IMAGE_NAME=${IMAGE_BASE}/logstash:prod" >> context.env
- echo "DOCKER_HUB_SCREEN_CLIENT_IMAGE=$DOCKER_HUB_USER/screens-client:${BUILD_ID}" >> context.env
- echo "DOCKER_HUB_BROWSER_CLIENT_IMAGE=$DOCKER_HUB_USER/browser-client:${BUILD_ID}" >> context.env
- echo "DOCKER_HUB_GATEWAY_IMAGE=$DOCKER_HUB_USER/gateway:${BUILD_ID}" >> context.env
- echo "DOCKER_HUB_SUBSCRIPTION_IMAGE=$DOCKER_HUB_USER/subs-manager:${BUILD_ID}" >> context.env
- echo "DOCKER_HUB_USER_MANAGER_IMAGE=$DOCKER_HUB_USER/user-manager:${BUILD_ID}" >> context.env
- echo "DOCKER_HUB_FLIGHT_INFO_IMAGE=$DOCKER_HUB_USER/flights-information:${BUILD_ID}" >> context.env
- echo "ENV_DEV_FILE=$(echo $ENV_DEV)" >> context.env
- echo "ENV_PROD_FILE=$(echo $ENV_PROD)" >> context.env
- echo "ENV_DEV_FILE=$(echo $ENV_DEV)" >> context.env
- echo "ENV_PROD_FILE=$(echo $ENV_PROD)" >> context.env
artifacts:
paths:
- context.env
build-auth-api:
.build-and-push-script: &build-and-push-script
- docker build ${FOLDER} -f ${FOLDER}/Dockerfile.prod --build-arg "${BUILD_ARG_PROD}" --build-arg "${BUILD_ARG_PROD_OTHER}" -t ${PROD_IMAGE}
- docker build ${FOLDER} -f ${FOLDER}/Dockerfile.test --build-arg "${BUILD_ARG_TEST}" -t ${TEST_IMAGE}
- docker push ${PROD_IMAGE}
- docker push ${TEST_IMAGE}
.build:
stage: build
tags:
- dev
script:
- export $(cat context.env | xargs)
- export USER_MANAGER=auth-domain/user-manager
- docker build $USER_MANAGER -f $USER_MANAGER/Dockerfile.prod -t ${USER_MANAGER_PROD_IMAGE_NAME}
- docker build $USER_MANAGER -f $USER_MANAGER/Dockerfile.test --build-arg "BASE_IMAGE=$USER_MANAGER_PROD_IMAGE_NAME" -t ${USER_MANAGER_TEST_IMAGE_NAME}
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker push ${USER_MANAGER_PROD_IMAGE_NAME}
- docker push ${USER_MANAGER_TEST_IMAGE_NAME}
needs:
- job: preparation
artifacts: true
build-auth-api:
extends:
- .build
script:
- export FOLDER=auth-domain/user-manager
- export PROD_IMAGE=${USER_MANAGER_PROD_IMAGE_NAME}
- export TEST_IMAGE=${USER_MANAGER_TEST_IMAGE_NAME}
- export BUILD_ARG_TEST="BASE_IMAGE=$USER_MANAGER_PROD_IMAGE_NAME"
- *build-and-push-script
build-flights-api:
stage: build
tags:
- dev
extends:
- .build
script:
- export $(cat context.env | xargs)
- export FLIGHTS_INFORMATION=flights-domain/flights-information
- docker build $FLIGHTS_INFORMATION -f $FLIGHTS_INFORMATION/Dockerfile.prod -t ${FLIGHTS_INFO_PROD_IMAGE_NAME}
- docker build $FLIGHTS_INFORMATION -f $FLIGHTS_INFORMATION/Dockerfile.test --build-arg "BASE_IMAGE=$FLIGHTS_INFO_PROD_IMAGE_NAME" -t ${FLIGHTS_INFO_TEST_IMAGE_NAME}
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker push ${FLIGHTS_INFO_PROD_IMAGE_NAME}
- docker push ${FLIGHTS_INFO_TEST_IMAGE_NAME}
needs:
- job: preparation
artifacts: true
- export FOLDER=flights-domain/flights-information
- export PROD_IMAGE=${FLIGHTS_INFO_PROD_IMAGE_NAME}
- export TEST_IMAGE=${FLIGHTS_INFO_TEST_IMAGE_NAME}
- export BUILD_ARG_TEST="BASE_IMAGE=$FLIGHTS_INFO_PROD_IMAGE_NAME"
- *build-and-push-script
build-browser-client:
stage: build
tags:
- dev
extends:
- .build
script:
- export $(cat context.env | xargs)
- docker build browser-domain -f browser-domain/Dockerfile.prod --build-arg "REACT_APP_ENDPOINT=https://api.fids.slc.ar/" -t ${BROWSER_CLIENT_PROD_IMAGE_NAME}
- docker build browser-domain -f browser-domain/Dockerfile.test -t ${BROWSER_CLIENT_TEST_IMAGE_NAME}
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker push ${BROWSER_CLIENT_PROD_IMAGE_NAME}
- docker push ${BROWSER_CLIENT_TEST_IMAGE_NAME}
needs:
- job: preparation
artifacts: true
- export FOLDER=browser-domain
- export PROD_IMAGE=${BROWSER_CLIENT_PROD_IMAGE_NAME}
- export TEST_IMAGE=${BROWSER_CLIENT_TEST_IMAGE_NAME}
- export BUILD_ARG_PROD="REACT_APP_ENDPOINT=https://api.fids.slc.ar/"
- *build-and-push-script
build-screen-client:
stage: build
tags:
- dev
extends:
- .build
script:
- export $(cat context.env | xargs)
- docker build screen-domain -f screen-domain/Dockerfile.prod --build-arg "REACT_APP_ENDPOINT=https://api.fids.slc.ar/" --build-arg "REACT_APP_ORIGIN=Frankfurt" -t ${SCREEN_CLIENT_PROD_IMAGE_NAME}
- docker build screen-domain -f screen-domain/Dockerfile.test -t ${SCREEN_CLIENT_TEST_IMAGE_NAME}
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker push ${SCREEN_CLIENT_PROD_IMAGE_NAME}
- docker push ${SCREEN_CLIENT_TEST_IMAGE_NAME}
needs:
- job: preparation
artifacts: true
- export FOLDER=screen-domain
- export PROD_IMAGE=${SCREEN_CLIENT_PROD_IMAGE_NAME}
- export TEST_IMAGE=${SCREEN_CLIENT_TEST_IMAGE_NAME}
- export BUILD_ARG_PROD="REACT_APP_ENDPOINT=https://api.fids.slc.ar/"
- export BUILD_ARG_PROD_OTHER="REACT_APP_ORIGIN=Frankfurt"
- *build-and-push-script
build-subscription-api:
stage: build
tags:
- dev
extends:
- .build
script:
- export $(cat context.env | xargs)
- export SUBSCRIPTION_MANAGER=subscription-domain/subscription-manager
- docker build $SUBSCRIPTION_MANAGER -f $SUBSCRIPTION_MANAGER/Dockerfile.prod -t ${SUBSCRIPTION_PROD_IMAGE_NAME}
- docker build $SUBSCRIPTION_MANAGER -f $SUBSCRIPTION_MANAGER/Dockerfile.test --build-arg "BASE_IMAGE=$SUBSCRIPTION_PROD_IMAGE_NAME" -t ${SUBSCRIPTION_TEST_IMAGE_NAME}
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker push ${SUBSCRIPTION_PROD_IMAGE_NAME}
- docker push ${SUBSCRIPTION_TEST_IMAGE_NAME}
needs:
- job: preparation
artifacts: true
- export FOLDER=subscription-domain/subscription-manager
- export PROD_IMAGE=${SUBSCRIPTION_PROD_IMAGE_NAME}
- export TEST_IMAGE=${SUBSCRIPTION_TEST_IMAGE_NAME}
- export BUILD_ARG_TEST="BASE_IMAGE=$SUBSCRIPTION_PROD_IMAGE_NAME"
- *build-and-push-script
build-gateway:
stage: build
tags:
- dev
extends:
- .build
script:
- export $(cat context.env | xargs)
- export FOLDER=gateway
- export PROD_IMAGE=${GATEWAY_PROD_IMAGE_NAME}
- export TEST_IMAGE=${GATEWAY_TEST_IMAGE_NAME}
- export BUILD_ARG_TEST="BASE_IMAGE=$GATEWAY_PROD_IMAGE_NAME"
- *build-and-push-script
- docker build gateway -f gateway/Dockerfile.prod -t ${GATEWAY_PROD_IMAGE_NAME}
- docker build gateway -f gateway/Dockerfile.test --build-arg "BASE_IMAGE=$GATEWAY_PROD_IMAGE_NAME" -t ${GATEWAY_TEST_IMAGE_NAME}
.test-script: &test-script
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit --renew-anon-volumes
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
.test-api-script: &test-api-script
- *test-script
- docker cp ${DOCKER_CONTAINER}:/usr/src/app/coverage.xml .
- docker cp ${DOCKER_CONTAINER}:/usr/src/app/report.xml .
- docker push ${GATEWAY_PROD_IMAGE_NAME}
- docker push ${GATEWAY_TEST_IMAGE_NAME}
needs:
- job: preparation
artifacts: true
test-auth-api:
.test-api:
stage: test
tags:
- dev
rules:
- changes:
- auth-domain/**/*
script:
- export $(cat context.env | xargs)
- export API_IMAGE=$USER_MANAGER_TEST_IMAGE_NAME
- export CLIENT_IMAGE=dummy-image
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit --renew-anon-volumes
- docker cp fids_usermanager_api:/usr/src/app/coverage.xml .
- docker cp fids_usermanager_api:/usr/src/app/report.xml .
artifacts:
when: always
paths:
@ -204,125 +151,84 @@ test-auth-api:
- report.xml
reports:
junit: report.xml
test-auth-api:
extends:
- .test-api
rules:
- changes:
- auth-domain/**/*
script:
- export API_IMAGE=${USER_MANAGER_TEST_IMAGE_NAME}
- export CLIENT_IMAGE=dummy-image
- export FOLDER=auth-domain
- export DOCKER_CONTAINER=fids_usermanager_api
- *test-api-script
needs:
- job: build-auth-api
- job: preparation
artifacts: true
test-subscription-api:
stage: test
tags:
- dev
extends:
- .test-api
rules:
- changes:
- subscription-domain/**/*
script:
- export $(cat context.env | xargs)
- export API_IMAGE=$SUBSCRIPTION_TEST_IMAGE_NAME
- export API_IMAGE=${SUBSCRIPTION_TEST_IMAGE_NAME}
- export CLIENT_IMAGE=dummy-image
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit --renew-anon-volumes
- docker cp fids_subscriptions_api:/usr/src/app/coverage.xml .
- docker cp fids_subscriptions_api:/usr/src/app/report.xml .
artifacts:
when: always
paths:
- coverage.xml
- report.xml
reports:
junit: report.xml
- export FOLDER=subscription-domain
- export DOCKER_CONTAINER=fids_subscriptions_api
- *test-api-script
needs:
- job: build-subscription-api
- job: preparation
artifacts: true
test-flights-api:
stage: test
tags:
- dev
extends:
- .test-api
rules:
- changes:
- flights-domain/**/*
script:
- export $(cat context.env | xargs)
- export API_IMAGE=$FLIGHTS_INFO_TEST_IMAGE_NAME
- export API_IMAGE=${FLIGHTS_INFO_TEST_IMAGE_NAME}
- export CLIENT_IMAGE=dummy-image
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit --renew-anon-volumes
- docker cp fids_flights_api:/usr/src/app/coverage.xml .
- docker cp fids_flights_api:/usr/src/app/report.xml .
artifacts:
when: always
paths:
- coverage.xml
- report.xml
reports:
junit: report.xml
- export FOLDER=flights-domain
- export DOCKER_CONTAINER=fids_flights_api
- *test-api-script
needs:
- job: build-flights-api
- job: preparation
artifacts: true
test-gateway:
stage: test
tags:
- dev
extends:
- .test-api
rules:
- changes:
- gateway/**/*
script:
- export $(cat context.env | xargs)
- export API_IMAGE=$GATEWAY_TEST_IMAGE_NAME
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit --renew-anon-volumes
- docker cp fids_api_gateway:/usr/src/app/coverage.xml .
- docker cp fids_api_gateway:/usr/src/app/report.xml .
artifacts:
when: always
paths:
- coverage.xml
- report.xml
reports:
junit: report.xml
- export API_IMAGE=${GATEWAY_TEST_IMAGE_NAME}
- export CLIENT_IMAGE=dummy-image
- export FOLDER=gateway
- export DOCKER_CONTAINER=fids_api_gateway
- *test-api-script
needs:
- job: build-gateway
- job: preparation
artifacts: true
test-browser-client:
stage: test
.test-client-script: &test-client-script
- *test-script
- docker cp ${DOCKER_CONTAINER}:/app/coverage/cobertura-coverage.xml .
- docker cp ${DOCKER_CONTAINER}:/app/junit.xml .
.test-client:
extends:
- .test-api
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
tags:
- dev
rules:
- changes:
- browser-domain/**/*
script:
- export $(cat context.env | xargs)
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- export CLIENT_IMAGE=$BROWSER_CLIENT_TEST_IMAGE_NAME
- docker compose -f browser-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f browser-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f browser-domain/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit
- docker cp fids_browser_client:/app/coverage/cobertura-coverage.xml .
- docker cp fids_browser_client:/app/junit.xml .
artifacts:
when: always
paths:
@ -332,44 +238,73 @@ test-browser-client:
coverage_report:
coverage_format: cobertura
path: cobertura-coverage.xml
test-browser-client:
extends:
- .test-client
rules:
- changes:
- browser-domain/**/*
script:
- export CLIENT_IMAGE=${BROWSER_CLIENT_TEST_IMAGE_NAME}
- export FOLDER=browser-domain
- export DOCKER_CONTAINER=fids_browser_client
- *test-client-script
needs:
- job: build-browser-client
- job: preparation
artifacts: true
test-screen-client:
stage: test
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
tags:
- dev
extends:
- .test-client
rules:
- changes:
- screen-domain/**/*
script:
- export $(cat context.env | xargs)
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- export CLIENT_IMAGE=$SCREEN_CLIENT_TEST_IMAGE_NAME
- docker compose -f screen-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f screen-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f screen-domain/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit
- docker cp fids_screens_client:/app/coverage/cobertura-coverage.xml .
- docker cp fids_screens_client:/app/junit.xml .
artifacts:
when: always
paths:
- cobertura-coverage.xml
reports:
junit: junit.xml
coverage_report:
coverage_format: cobertura
path: cobertura-coverage.xml
- export CLIENT_IMAGE=${SCREEN_CLIENT_TEST_IMAGE_NAME}
- export FOLDER=screen-domain
- export DOCKER_CONTAINER=fids_screens_client
- *test-client-script
needs:
- job: build-screen-client
- job: preparation
artifacts: true
.test-integration: &test-integration
- export TEST_TARGET=INTEGRATION
- export API_IMAGE=$FLIGHTS_INFO_TEST_IMAGE_NAME
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- export API_IMAGE=$GATEWAY_TEST_IMAGE_NAME
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- export API_IMAGE=$USER_MANAGER_TEST_IMAGE_NAME
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE exec usermanager-api python manage.py recreate_db
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE exec usermanager-api python manage.py seed_db
- export API_IMAGE=$SUBSCRIPTION_TEST_IMAGE_NAME
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit
.test-integration-clean: &test-integration-clean
- export API_IMAGE=${FLIGHTS_INFO_TEST_IMAGE_NAME}
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- export API_IMAGE=${USER_MANAGER_TEST_IMAGE_NAME}
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- export API_IMAGE=${SUBSCRIPTION_TEST_IMAGE_NAME}
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- export API_IMAGE=${GATEWAY_TEST_IMAGE_NAME}
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE down
test-browser-integration:
stage: test
tags:
@ -382,37 +317,11 @@ test-browser-integration:
- subscription-domain/**/*
- gateway/**/*
script:
- export $(cat context.env | xargs)
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- export TEST_TARGET=INTEGRATION
- export API_IMAGE=$FLIGHTS_INFO_TEST_IMAGE_NAME
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- export API_IMAGE=$GATEWAY_TEST_IMAGE_NAME
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- export API_IMAGE=$USER_MANAGER_TEST_IMAGE_NAME
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE exec usermanager-api python manage.py recreate_db
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE exec usermanager-api python manage.py seed_db
- export API_IMAGE=$SUBSCRIPTION_TEST_IMAGE_NAME
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- export CLIENT_IMAGE=$BROWSER_CLIENT_TEST_IMAGE_NAME
- docker compose -f browser-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f browser-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f browser-domain/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit
- export CLIENT_IMAGE=${BROWSER_CLIENT_TEST_IMAGE_NAME}
- export FOLDER=browser-domain
- *test-integration
after_script:
- *test-integration-clean
needs:
- job: test-flights-api
optional: true
@ -439,37 +348,11 @@ test-screen-integration:
- subscription-domain/**/*
- gateway/**/*
script:
- export $(cat context.env | xargs)
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- export TEST_TARGET=INTEGRATION
- export API_IMAGE=$FLIGHTS_INFO_TEST_IMAGE_NAME
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- export API_IMAGE=$GATEWAY_TEST_IMAGE_NAME
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- export API_IMAGE=$USER_MANAGER_TEST_IMAGE_NAME
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE exec usermanager-api python manage.py recreate_db
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE exec usermanager-api python manage.py seed_db
- export API_IMAGE=$SUBSCRIPTION_TEST_IMAGE_NAME
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE up -d
- export CLIENT_IMAGE=$SCREEN_CLIENT_TEST_IMAGE_NAME
- docker compose -f screen-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- docker compose -f screen-domain/docker-compose.yml --env-file $ENV_DEV_FILE pull
- docker compose -f screen-domain/docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit
- export CLIENT_IMAGE=${SCREEN_CLIENT_TEST_IMAGE_NAME}
- export FOLDER=screen-domain
- *test-integration
after_script:
- *test-integration-clean
needs:
- job: test-flights-api
optional: true
@ -486,37 +369,6 @@ test-screen-integration:
- job: preparation
artifacts: true
test-clean:
stage: test
tags:
- dev
rules:
- changes:
- auth-domain/**/*
- screen-domain/**/*
- browser-domain/**/*
- flights-domain/**/*
- subscription-domain/**/*
- gateway/**/*
script:
- export $(cat context.env | xargs)
- export API_IMAGE=$FLIGHTS_INFO_TEST_IMAGE_NAME
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- export API_IMAGE=$USER_MANAGER_TEST_IMAGE_NAME
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- export API_IMAGE=$SUBSCRIPTION_TEST_IMAGE_NAME
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_DEV_FILE down
- export API_IMAGE=$GATEWAY_TEST_IMAGE_NAME
- docker compose -f gateway/docker-compose.yml --env-file $ENV_DEV_FILE down
needs:
- job: test-screen-integration
optional: true
- job: test-browser-integration
optional: true
- job: preparation
artifacts: true
deliver-dockerhub:
stage: deliver
tags:
@ -531,9 +383,6 @@ deliver-dockerhub:
- gateway/**/*
- if: $FORCE_DEPLOY == "true"
script:
- export $(cat context.env | xargs)
- docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY
- docker login -u $DOCKER_HUB_USER --password $DOCKER_HUB_PASS
- docker tag $FLIGHTS_INFO_PROD_IMAGE_NAME $DOCKER_HUB_FLIGHT_INFO_IMAGE
@ -550,41 +399,41 @@ deliver-dockerhub:
- docker push $DOCKER_HUB_BROWSER_CLIENT_IMAGE
- docker push $DOCKER_HUB_SCREEN_CLIENT_IMAGE
needs:
- job: test-clean
- job: test-screen-integration
optional: true
- job: preparation
artifacts: true
build-and-run-elk:
stage: build
tags:
- dev
extends:
- .build
rules:
- changes:
- observability/**/*
script:
- export $(cat context.env | xargs)
- export ELASTICSEARCH_IMAGE=${ELASTIC_PROD_IMAGE_NAME}
- export ELK_SETUP_IMAGE=${ELK_SETUP_PROD_IMAGE_NAME}
- export LOGSTASH_IMAGE=${LOGSTASH_PROD_IMAGE_NAME}
- export KIBANA_IMAGE=${KIBANA_PROD_IMAGE_NAME}
- export CURATOR_IMAGE=${CURATOR_PROD_IMAGE_NAME}
- export HEARTBEAT_IMAGE=${HEARTBEAT_PROD_IMAGE_NAME}
- export ELK_SETUP_IMAGE=${IMAGE_BASE}/elasticsearch:prod
- export ELASTICSEARCH_IMAGE=${IMAGE_BASE}/elk-setup:prod
- export LOGSTASH_IMAGE=${IMAGE_BASE}/heartbeat:prod
- export KIBANA_IMAGE=${IMAGE_BASE}/kibana:prod
- export CURATOR_IMAGE=${IMAGE_BASE}/curator:prod
- export HEARTBEAT_IMAGE=${IMAGE_BASE}/logstash:prod
- export ELK=observability/elk
- docker build $ELK/setup -f $ELK/setup/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${ELK_SETUP_PROD_IMAGE_NAME}
- docker build $ELK/elasticsearch -f $ELK/elasticsearch/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${ELASTIC_PROD_IMAGE_NAME}
- docker build $ELK/logstash -f $ELK/logstash/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${LOGSTASH_PROD_IMAGE_NAME}
- docker build $ELK/kibana -f $ELK/kibana/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${KIBANA_PROD_IMAGE_NAME}
- docker build $ELK/extensions/curator -f $ELK/extensions/curator/Dockerfile -t ${CURATOR_PROD_IMAGE_NAME}
- docker build $ELK/extensions/heartbeat -f $ELK/extensions/heartbeat/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${HEARTBEAT_PROD_IMAGE_NAME}
- docker build $ELK/setup -f $ELK/setup/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${ELK_SETUP_IMAGE}
- docker build $ELK/elasticsearch -f $ELK/elasticsearch/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${ELASTICSEARCH_IMAGE}
- docker build $ELK/logstash -f $ELK/logstash/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${LOGSTASH_IMAGE}
- docker build $ELK/kibana -f $ELK/kibana/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${KIBANA_IMAGE}
- docker build $ELK/extensions/curator -f $ELK/extensions/curator/Dockerfile -t ${CURATOR_IMAGE}
- docker build $ELK/extensions/heartbeat -f $ELK/extensions/heartbeat/Dockerfile --build-arg "ELASTIC_VERSION=8.7.1" -t ${HEARTBEAT_IMAGE}
- docker compose -f observability/docker-compose.yml --env-file $ENV_DEV_FILE --profile setup up -d
- docker compose -f observability/docker-compose.yml -f $ELK/extensions/curator/curator-compose.yml -f $ELK/extensions/heartbeat/heartbeat-compose.yml --env-file $ENV_DEV_FILE up -d
needs:
- job: preparation
artifacts: true
.stop-and-run: &stop-and-run
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_PROD_FILE stop
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_PROD_FILE rm -f
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_PROD_FILE pull
- docker compose -f ${FOLDER}/docker-compose.yml --env-file $ENV_PROD_FILE up -d
deploy-prod:
stage: deploy
@ -601,46 +450,33 @@ deploy-prod:
- gateway/**/*
- if: $FORCE_DEPLOY == "true"
script:
- export $(cat context.env | xargs)
- docker login -u $DOCKER_HUB_USER --password $DOCKER_HUB_PASS
- export API_IMAGE=$DOCKER_HUB_FLIGHT_INFO_IMAGE
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_PROD_FILE stop
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_PROD_FILE rm -f
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_PROD_FILE pull
- docker compose -f flights-domain/docker-compose.yml --env-file $ENV_PROD_FILE up -d
- export FOLDER=flights-domain
- *stop-and-run
- export API_IMAGE=$DOCKER_HUB_USER_MANAGER_IMAGE
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_PROD_FILE stop
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_PROD_FILE rm -f
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_PROD_FILE pull
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_PROD_FILE up -d
- export FOLDER=auth-domain
- *stop-and-run
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_PROD_FILE exec usermanager-api python manage.py recreate_db
- docker compose -f auth-domain/docker-compose.yml --env-file $ENV_PROD_FILE exec usermanager-api python manage.py seed_db
- export API_IMAGE=$DOCKER_HUB_SUBSCRIPTION_IMAGE
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_PROD_FILE stop
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_PROD_FILE rm -f
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_PROD_FILE pull
- docker compose -f subscription-domain/docker-compose.yml --env-file $ENV_PROD_FILE up -d
- export FOLDER=subscription-domain
- *stop-and-run
- export API_IMAGE=$DOCKER_HUB_GATEWAY_IMAGE
- docker compose -f gateway/docker-compose.yml --env-file $ENV_PROD_FILE stop
- docker compose -f gateway/docker-compose.yml --env-file $ENV_PROD_FILE rm -f
- docker compose -f gateway/docker-compose.yml --env-file $ENV_PROD_FILE pull
- docker compose -f gateway/docker-compose.yml --env-file $ENV_PROD_FILE up -d
- export FOLDER=gateway
- *stop-and-run
- export CLIENT_IMAGE=$DOCKER_HUB_SCREEN_CLIENT_IMAGE
- docker compose -f screen-domain/docker-compose.yml stop
- docker compose -f screen-domain/docker-compose.yml rm -f
- docker compose -f screen-domain/docker-compose.yml pull
- docker compose -f screen-domain/docker-compose.yml up -d
- export FOLDER=screen-domain
- *stop-and-run
- export CLIENT_IMAGE=$DOCKER_HUB_BROWSER_CLIENT_IMAGE
- docker compose -f browser-domain/docker-compose.yml stop
- docker compose -f browser-domain/docker-compose.yml rm -f
- docker compose -f browser-domain/docker-compose.yml pull
- docker compose -f browser-domain/docker-compose.yml up -d
- export FOLDER=browser-domain
- *stop-and-run
needs:
- job: deliver-dockerhub
optional: true