diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea3b96aad..af257dff9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,19 +54,60 @@ dynamic:prepare: - apt-get -y update - apt-get -y install git script: - - FRONTEND_IMAGE_VERSION=`git log docker/frontend/Dockerfile | grep '^commit' | wc --lines` - - BACKEND_IMAGE_VERSION=`git log docker/backend/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 | tee backend-image-version` - 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 artifacts: paths: + - frontend-image-version + - backend-image-version - frontend.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: stage: frontend needs: - dynamic:prepare + - job: container:frontend + optional: true trigger: strategy: depend include: @@ -77,6 +118,8 @@ backend: stage: backend needs: - dynamic:prepare + - job: container:backend + optional: true - frontend trigger: strategy: depend diff --git a/.gitlab-ci/backend.yml b/.gitlab-ci/backend.yml index 9dadf2375..6e798d9dc 100644 --- a/.gitlab-ci/backend.yml +++ b/.gitlab-ci/backend.yml @@ -33,27 +33,6 @@ default: 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: stage: compile needs: diff --git a/.gitlab-ci/frontend.yml b/.gitlab-ci/frontend.yml index d37c0283d..99693ac1d 100644 --- a/.gitlab-ci/frontend.yml +++ b/.gitlab-ci/frontend.yml @@ -15,7 +15,6 @@ variables: FRONTEND_IMAGE_VERSION: #dyn# stages: - - container - compile - lint - test @@ -33,33 +32,8 @@ default: 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: stage: compile - needs: - - job: container - optional: true # image: &frontend-image ${CI_REGISTRY_IMAGE}/frontend/${CI_COMMIT_REF_SLUG}:${FRONTEND_IMAGE_VERSION} script: # - &load-frontend-image zcat docker/frontend/image.tar.gz | podman image load @@ -79,8 +53,6 @@ compile: lint: stage: lint needs: - - job: container - optional: true # image: *frontend-image script: # - *load-frontend-image @@ -91,13 +63,10 @@ lint: test: stage: test needs: - - job: container - optional: true - compile # image: *frontend-image script: # - *load-frontend-image # - make -- --docker-run-frontend-test FRADRIVE_SERVICE=frontend CONTAINER_RUNNER=podman-compose - make -- frontend-test FRADRIVE_SERVICE=frontend - cache: *frontend-cache