diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a69f2b3..9930d7b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,13 +19,22 @@ preparation: - export BUILD_ID=$(date +%Y%m%d%H%M) - echo "BUILD_ID=${BUILD_ID}" > context.env - - echo "API_PROD_IMAGE_NAME=${IMAGE_BASE}/api:prod-${BUILD_ID}" >> context.env - - echo "API_TEST_IMAGE_NAME=${IMAGE_BASE}/api:test-${BUILD_ID}" >> context.env - - echo "CLIENT_PROD_IMAGE_NAME=${IMAGE_BASE}/client:prod-${BUILD_ID}" >> context.env - - echo "CLIENT_TEST_IMAGE_NAME=${IMAGE_BASE}/client:test-${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 "DOCKER_HUB_API_IMAGE=$DOCKER_HUB_USER/fids-api:${BUILD_ID}" >> context.env - - echo "DOCKER_HUB_CLIENT_IMAGE=$DOCKER_HUB_USER/fids-client:${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 "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 "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_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 @@ -33,58 +42,96 @@ preparation: paths: - context.env -build-api: +build-auth-api: stage: build tags: - dev script: - export $(cat context.env | xargs) - - docker build flights-domain -f flights-domain/Dockerfile.prod -t ${API_PROD_IMAGE_NAME} - - docker build flights-domain -f flights-domain/Dockerfile.test --build-arg "BASE_IMAGE=$API_PROD_IMAGE_NAME" -t ${API_TEST_IMAGE_NAME} + - 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 ${API_PROD_IMAGE_NAME} - - docker push ${API_TEST_IMAGE_NAME} + - docker push ${USER_MANAGER_PROD_IMAGE_NAME} + - docker push ${USER_MANAGER_TEST_IMAGE_NAME} needs: - job: preparation artifacts: true -build-client: +build-flights-api: stage: build tags: - dev script: - export $(cat context.env | xargs) - - docker build sample-client-users -f sample-client-users/Dockerfile.prod -t ${CLIENT_PROD_IMAGE_NAME} - - docker build sample-client-users -f sample-client-users/Dockerfile.test -t ${CLIENT_TEST_IMAGE_NAME} + - 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 ${CLIENT_PROD_IMAGE_NAME} - - docker push ${CLIENT_TEST_IMAGE_NAME} + - docker push ${FLIGHTS_INFO_PROD_IMAGE_NAME} + - docker push ${FLIGHTS_INFO_TEST_IMAGE_NAME} needs: - job: preparation artifacts: true -test-api: +build-browser-client: + stage: build + tags: + - dev + script: + - export $(cat context.env | xargs) + + - docker build browser-domain -f browser-domain/Dockerfile.prod -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 + +build-screen-client: + stage: build + tags: + - dev + script: + - export $(cat context.env | xargs) + + - docker build screen-domain -f screen-domain/Dockerfile.prod -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 + +test-auth-api: stage: test tags: - dev script: - export $(cat context.env | xargs) - - export API_IMAGE=$API_TEST_IMAGE_NAME + - export API_IMAGE=$BROWSER_CLIENT_TEST_IMAGE_NAME - export CLIENT_IMAGE=dummy-image - docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY - - docker compose -f docker-compose.yml --env-file $ENV_DEV_FILE --profile api pull - - docker compose -f docker-compose.yml --env-file $ENV_DEV_FILE --profile api up --abort-on-container-exit --renew-anon-volumes - - docker cp fids_api:/usr/src/app/coverage.xml . - - docker cp fids_api:/usr/src/app/report.xml . + - 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: @@ -94,7 +141,35 @@ test-api: junit: report.xml needs: - job: preparation - - job: build-api + - job: build-auth-api + artifacts: true + +test-flights-api: + stage: test + tags: + - dev + script: + - export $(cat context.env | xargs) + + - 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 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 + needs: + - job: preparation + - job: build-flights-api artifacts: true test-integration: @@ -108,11 +183,13 @@ test-integration: - export API_IMAGE=$API_TEST_IMAGE_NAME - export CLIENT_IMAGE=$CLIENT_TEST_IMAGE_NAME - export TEST_TARGET=INTEGRATION - - docker compose -f docker-compose.yml --env-file $ENV_DEV_FILE --profile all pull - - docker compose -f docker-compose.yml --env-file $ENV_DEV_FILE --profile all up --abort-on-container-exit + # - docker compose -f docker-compose.yml --env-file $ENV_DEV_FILE pull + # - docker compose -f docker-compose.yml --env-file $ENV_DEV_FILE up --abort-on-container-exit needs: - - job: test-api - - job: build-client + - job: test-flights-api + - job: test-auth-api + - job: build-browser-client + - job: build-screen-client - job: preparation artifacts: true @@ -126,11 +203,15 @@ deliver-dockerhub: - docker login -u $CI_REGISTRY_USER --password $CI_JOB_TOKEN $CI_REGISTRY - docker login -u $DOCKER_HUB_USER --password $DOCKER_HUB_PASS - - docker tag $API_PROD_IMAGE_NAME $DOCKER_HUB_API_IMAGE - - docker tag $CLIENT_PROD_IMAGE_NAME $DOCKER_HUB_CLIENT_IMAGE + - docker tag $FLIGHTS_INFO_PROD_IMAGE_NAME $DOCKER_HUB_FLIGHT_INFO_IMAGE + - docker tag $USER_MANAGER_PROD_IMAGE_NAME $DOCKER_HUB_USER_MANAGER_IMAGE + - docker tag $BROWSER_CLIENT_PROD_IMAGE_NAME $DOCKER_HUB_BROWSER_CLIENT_IMAGE + - docker tag $SCREEN_CLIENT_PROD_IMAGE_NAME $DOCKER_HUB_SCREEN_CLIENT_IMAGE - - docker push $DOCKER_HUB_API_IMAGE - - docker push $DOCKER_HUB_CLIENT_IMAGE + - docker push $DOCKER_HUB_FLIGHT_INFO_IMAGE + - docker push $DOCKER_HUB_USER_MANAGER_IMAGE + - docker push $DOCKER_HUB_BROWSER_CLIENT_IMAGE + - docker push $DOCKER_HUB_SCREEN_CLIENT_IMAGE needs: - job: test-integration - job: preparation @@ -152,10 +233,10 @@ deploy-prod: - docker login -u $DOCKER_HUB_USER --password $DOCKER_HUB_PASS - - docker compose -f docker-compose.yml --profile all --env-file $ENV_PROD_FILE stop - - docker compose -f docker-compose.yml --profile all --env-file $ENV_PROD_FILE rm -f - - docker compose -f docker-compose.yml --profile all --env-file $ENV_PROD_FILE pull - - docker compose -f docker-compose.yml --profile all --env-file $ENV_PROD_FILE up -d + - docker compose -f docker-compose.yml --env-file $ENV_PROD_FILE stop + - docker compose -f docker-compose.yml --env-file $ENV_PROD_FILE rm -f + - docker compose -f docker-compose.yml --env-file $ENV_PROD_FILE pull + - docker compose -f docker-compose.yml --env-file $ENV_PROD_FILE up -d needs: - job: deliver-dockerhub - job: preparation