ci(gitlab-ci): make container builds independent from code builds
This commit is contained in:
parent
b45b7452ea
commit
35e77e2d1d
@ -54,19 +54,60 @@ dynamic:prepare:
|
|||||||
- apt-get -y update
|
- apt-get -y update
|
||||||
- apt-get -y install git
|
- apt-get -y install git
|
||||||
script:
|
script:
|
||||||
- FRONTEND_IMAGE_VERSION=`git log docker/frontend/Dockerfile | grep '^commit' | wc --lines`
|
- FRONTEND_IMAGE_VERSION=`git log docker/frontend/Dockerfile | grep '^commit' | wc --lines | tee frontend-image-version`
|
||||||
- BACKEND_IMAGE_VERSION=`git log docker/backend/Dockerfile | grep '^commit' | wc --lines`
|
- BACKEND_IMAGE_VERSION=`git log docker/backend/Dockerfile | grep '^commit' | wc --lines | tee backend-image-version`
|
||||||
- cat .gitlab-ci/frontend.yml | .gitlab-ci/dynamci.pl FRONTEND_IMAGE_VERSION=${FRONTEND_IMAGE_VERSION} > frontend.yml
|
- cat .gitlab-ci/frontend.yml | .gitlab-ci/dynamci.pl FRONTEND_IMAGE_VERSION=${FRONTEND_IMAGE_VERSION} > frontend.yml
|
||||||
- cat .gitlab-ci/backend.yml | .gitlab-ci/dynamci.pl BACKEND_IMAGE_VERSION=${BACKEND_IMAGE_VERSION} > backend.yml
|
- cat .gitlab-ci/backend.yml | .gitlab-ci/dynamci.pl BACKEND_IMAGE_VERSION=${BACKEND_IMAGE_VERSION} > backend.yml
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
|
- frontend-image-version
|
||||||
|
- backend-image-version
|
||||||
- frontend.yml
|
- frontend.yml
|
||||||
- backend.yml
|
- backend.yml
|
||||||
|
|
||||||
|
container:frontend: &container:frontend
|
||||||
|
stage: prepare
|
||||||
|
needs:
|
||||||
|
- dynamic:prepare
|
||||||
|
image: ${IMAGE_BUILDER}
|
||||||
|
script:
|
||||||
|
- FRONTEND_IMAGE_VERSION=`cat frontend-image-version`
|
||||||
|
- buildah bud -t frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} docker/frontend/Dockerfile
|
||||||
|
- buildah push --creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} ${CI_REGISTRY_IMAGE}/frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION}
|
||||||
|
rules:
|
||||||
|
- changes:
|
||||||
|
- docker/frontend/Dockerfile
|
||||||
|
interruptible: false
|
||||||
|
container:frontend:manual:
|
||||||
|
<<: *container:frontend
|
||||||
|
rules:
|
||||||
|
- when: manual
|
||||||
|
|
||||||
|
container:backend: &container:backend
|
||||||
|
stage: prepare
|
||||||
|
needs:
|
||||||
|
- dynamic:prepare
|
||||||
|
image: ${IMAGE_BUILDER}
|
||||||
|
script:
|
||||||
|
- BACKEND_IMAGE_VERSION=`cat backend-image-version`
|
||||||
|
- buildah bud -t backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION} docker/backend/Dockerfile
|
||||||
|
- buildah push --creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION} ${CI_REGISTRY_IMAGE}/backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION}
|
||||||
|
rules:
|
||||||
|
- changes:
|
||||||
|
- docker/backend/Dockerfile
|
||||||
|
interruptible: false
|
||||||
|
container:backend:manual:
|
||||||
|
<<: *container:backend
|
||||||
|
rules:
|
||||||
|
- when: manual
|
||||||
|
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
stage: frontend
|
stage: frontend
|
||||||
needs:
|
needs:
|
||||||
- dynamic:prepare
|
- dynamic:prepare
|
||||||
|
- job: container:frontend
|
||||||
|
optional: true
|
||||||
trigger:
|
trigger:
|
||||||
strategy: depend
|
strategy: depend
|
||||||
include:
|
include:
|
||||||
@ -77,6 +118,8 @@ backend:
|
|||||||
stage: backend
|
stage: backend
|
||||||
needs:
|
needs:
|
||||||
- dynamic:prepare
|
- dynamic:prepare
|
||||||
|
- job: container:backend
|
||||||
|
optional: true
|
||||||
- frontend
|
- frontend
|
||||||
trigger:
|
trigger:
|
||||||
strategy: depend
|
strategy: depend
|
||||||
|
|||||||
@ -33,27 +33,6 @@ default:
|
|||||||
interruptible: true
|
interruptible: true
|
||||||
|
|
||||||
|
|
||||||
container:
|
|
||||||
stage: container
|
|
||||||
image: ${IMAGE_BUILDER}
|
|
||||||
script:
|
|
||||||
- buildah bud -t backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION} docker/backend/Dockerfile
|
|
||||||
- buildah push --creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION} ${CI_REGISTRY_IMAGE}/backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION}
|
|
||||||
rules:
|
|
||||||
- changes:
|
|
||||||
- docker/backend/Dockerfile
|
|
||||||
interruptible: false
|
|
||||||
|
|
||||||
container-manual:
|
|
||||||
stage: container
|
|
||||||
image: ${IMAGE_BUILDER}
|
|
||||||
script:
|
|
||||||
- buildah bud -t backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION} docker/backend/Dockerfile
|
|
||||||
- buildah push --creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION} ${CI_REGISTRY_IMAGE}/backend/${CI_COMMIT_REF_SLUG}:${BACKEND_IMAGE_VERSION}
|
|
||||||
rules:
|
|
||||||
- when: manual
|
|
||||||
interruptible: false
|
|
||||||
|
|
||||||
compile:
|
compile:
|
||||||
stage: compile
|
stage: compile
|
||||||
needs:
|
needs:
|
||||||
|
|||||||
@ -15,7 +15,6 @@ variables:
|
|||||||
FRONTEND_IMAGE_VERSION: #dyn#
|
FRONTEND_IMAGE_VERSION: #dyn#
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- container
|
|
||||||
- compile
|
- compile
|
||||||
- lint
|
- lint
|
||||||
- test
|
- test
|
||||||
@ -33,33 +32,8 @@ default:
|
|||||||
interruptible: true
|
interruptible: true
|
||||||
|
|
||||||
|
|
||||||
container:
|
|
||||||
stage: container
|
|
||||||
image: ${IMAGE_BUILDER}
|
|
||||||
script:
|
|
||||||
- buildah bud -t frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} docker/frontend/Dockerfile
|
|
||||||
- buildah push --creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} ${CI_REGISTRY_IMAGE}/frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION}
|
|
||||||
rules:
|
|
||||||
- changes:
|
|
||||||
- docker/frontend/Dockerfile
|
|
||||||
interruptible: false
|
|
||||||
|
|
||||||
container-manual:
|
|
||||||
stage: container
|
|
||||||
image: ${IMAGE_BUILDER}
|
|
||||||
script:
|
|
||||||
- buildah bud -t frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} docker/frontend/Dockerfile
|
|
||||||
- buildah push --creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} ${CI_REGISTRY_IMAGE}/frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION}
|
|
||||||
rules:
|
|
||||||
- when: manual
|
|
||||||
interruptible: false
|
|
||||||
|
|
||||||
|
|
||||||
compile:
|
compile:
|
||||||
stage: compile
|
stage: compile
|
||||||
needs:
|
|
||||||
- job: container
|
|
||||||
optional: true
|
|
||||||
# image: &frontend-image ${CI_REGISTRY_IMAGE}/frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION}
|
# image: &frontend-image ${CI_REGISTRY_IMAGE}/frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION}
|
||||||
script:
|
script:
|
||||||
# - &load-frontend-image zcat docker/frontend/image.tar.gz | podman image load
|
# - &load-frontend-image zcat docker/frontend/image.tar.gz | podman image load
|
||||||
@ -79,8 +53,6 @@ compile:
|
|||||||
lint:
|
lint:
|
||||||
stage: lint
|
stage: lint
|
||||||
needs:
|
needs:
|
||||||
- job: container
|
|
||||||
optional: true
|
|
||||||
# image: *frontend-image
|
# image: *frontend-image
|
||||||
script:
|
script:
|
||||||
# - *load-frontend-image
|
# - *load-frontend-image
|
||||||
@ -91,13 +63,10 @@ lint:
|
|||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
needs:
|
needs:
|
||||||
- job: container
|
|
||||||
optional: true
|
|
||||||
- compile
|
- compile
|
||||||
# image: *frontend-image
|
# image: *frontend-image
|
||||||
script:
|
script:
|
||||||
# - *load-frontend-image
|
# - *load-frontend-image
|
||||||
# - make -- --docker-run-frontend-test FRADRIVE_SERVICE=frontend CONTAINER_RUNNER=podman-compose
|
# - make -- --docker-run-frontend-test FRADRIVE_SERVICE=frontend CONTAINER_RUNNER=podman-compose
|
||||||
- make -- frontend-test FRADRIVE_SERVICE=frontend
|
- make -- frontend-test FRADRIVE_SERVICE=frontend
|
||||||
|
|
||||||
cache: *frontend-cache
|
cache: *frontend-cache
|
||||||
|
|||||||
Reference in New Issue
Block a user