docker: multi tag builds

This commit is contained in:
Mohamed Sohail 2021-10-05 09:18:29 +03:00
parent 8a9d2ee0be
commit f3aa081510
Signed by: kamikazechaser
GPG Key ID: 7DD45520C01CD85D
2 changed files with 37 additions and 49 deletions

View File

@ -1,43 +1,14 @@
include: default:
#- local: 'ci_templates/.cic-template.yml' #kaniko build templates image: docker:latest
# these includes are app specific unit tests tags:
- local: 'apps/cic-eth/.gitlab-ci.yml' - cic-runner
- local: 'apps/cic-ussd/.gitlab-ci.yml'
- local: 'apps/cic-notify/.gitlab-ci.yml'
- local: 'apps/cic-meta/.gitlab-ci.yml'
- local: 'apps/cic-cache/.gitlab-ci.yml'
#- local: 'apps/contract-migration/.gitlab-ci.yml'
#- local: 'apps/data-seeding/.gitlab-ci.yml'
stages:
- build
- test
- deploy
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/docker-with-compose:latest
variables: variables:
REGISTRY: registry.gitlab.com/kamikazechaser/cic-monorepo
DOCKER_BUILDKIT: "1" DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
CI_DEBUG_TRACE: "true"
before_script: before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
# runs on protected branches and pushes to repo include:
build-push: - local: 'apps/cic-eth/.gitlab-ci.yml'
stage: build
tags:
- integration
#script:
# - TAG=$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA sh ./scripts/build-push.sh
script:
- TAG=latest sh ./scripts/build-push.sh
rules:
- if: $CI_COMMIT_REF_PROTECTED == "true"
when: always
deploy-dev:
stage: deploy
trigger: grassrootseconomics/devops
when: manual

View File

@ -1,16 +1,33 @@
build-test-cic-eth: stages:
stage: test - build-push
tags: - test
- integration
variables: variables:
APP_NAME: cic-eth APP_NAME: cic-eth
MR_IMAGE_TAG: mr-$APP_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
workflow:
rules:
- changes:
- apps/$APP_NAME/**/*
cic-eth:build-push:
stage: build-push
script: script:
- cd apps/cic-eth - cd apps/$APP_NAME
- docker build -t $MR_IMAGE_TAG -f docker/Dockerfile . - docker pull $REGISTRY/$APP_NAME:latest || true
- docker run $MR_IMAGE_TAG sh docker/run_tests.sh - docker build --cache-from $REGISTRY/$APP_NAME:latest -t $REGISTRY/$APP_NAME:$CI_COMMIT_SHORT_SHA -f docker/Dockerfile .
- docker push $REGISTRY/$APP_NAME --all-tags
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_REF_PROTECTED == "true"
cic-eth:test:
variables:
GIT_STRATEGY: none
stage: test
needs: ["cic-eth:build-push"]
variables:
allow_failure: true
script:
- docker run $REGISTRY/$APP_NAME:$CI_COMMIT_SHORT_SHA sh docker/run_tests.sh
rules: rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- apps/$APP_NAME/**/*
when: always