Commit 68df3960 authored by svwolter's avatar svwolter
Browse files

Revise CI/CD pipeline

parent 1a8b76f6
Pipeline #37883 passed with stages
in 6 minutes and 56 seconds
image: node:lts-alpine
variables:
DOCKER_TLS_CERTDIR: ""
REGISTRY: $CI_REGISTRY
REGISTRY_USER: $CI_REGISTRY_USER
REGISTRY_PASSWORD: $CI_REGISTRY_PASSWORD
REGISTRY_PROJECT: "/${CI_PROJECT_PATH}/"
stages:
- setup
- build
- test
- packetize
- deploy
.default_rules:
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH == "develop"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
install-dependencies:
stage: setup
interruptible: true
only:
- main
- merge_requests
rules:
- !reference [.default_rules, rules]
- if: $CI_COMMIT_TAG
cache:
key:
files:
......@@ -28,9 +40,9 @@ install-dependencies:
.distributed:
interruptible: true
only:
- main
- merge_requests
rules:
- !reference [.default_rules, rules]
- if: $CI_COMMIT_TAG
needs:
- install-dependencies
artifacts:
......@@ -40,6 +52,10 @@ install-dependencies:
build-app:
stage: build
extends: .distributed
rules:
- !reference [ .default_rules, rules ]
- if: $CI_COMMIT_TAG
when: never
script:
- apk update && apk add git
- npx nx affected --base=HEAD~1 --target=build --parallel=3
......@@ -47,27 +63,82 @@ build-app:
paths:
- dist
build-release:
stage: build
extends: .distributed
rules:
- if: $CI_COMMIT_TAG
script:
- apk update && apk add git
- npx nx run-many --target=build --all --parallel
artifacts:
paths:
- dist
test-app:
stage: test
extends: .distributed
rules:
- !reference [ .default_rules, rules ]
- if: $CI_COMMIT_TAG
when: never
script:
- apk update && apk add git
- npx nx affected --base=HEAD~1 --target=test --parallel=2
build-docker-image:
test-release:
stage: test
extends: .distributed
rules:
- if: $CI_COMMIT_TAG
script:
- apk update && apk add git
- npx nx run-many --target=test --all --parallel
build-docker-db:
stage: packetize
image: docker:git
services:
- docker:dind
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == "main"
changes:
- scripts/db/Dockerfile
- scripts/db/conf/*
- scripts/db/init/*
- if: $CI_COMMIT_BRANCH == "develop"
changes:
- scripts/db/Dockerfile
- scripts/db/conf/*
- scripts/db/init/*
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- scripts/db/Dockerfile
- scripts/db/conf/*
- scripts/db/init/*
before_script:
- export TAG=$(git rev-parse --short HEAD)
- echo "$REGISTRY_PASSWORD" | docker login -u $REGISTRY_USER --password-stdin $REGISTRY
script:
- docker build -f scripts/db/Dockerfile --target=prod -t ${REGISTRY}${REGISTRY_PROJECT}iqbberlin/personaldb-db:${TAG} .
- docker push ${REGISTRY}${REGISTRY_PROJECT}iqbberlin/personaldb-db:${TAG}
after_script:
- docker logout $REGISTRY
build-docker-app:
stage: packetize
extends: .distributed
rules:
- !reference [ .default_rules, rules ]
- if: $CI_COMMIT_TAG
when: never
needs:
- install-dependencies
- build-app
- test-app
image: docker:git
variables:
DOCKER_TLS_CERTDIR: ""
REGISTRY: $CI_REGISTRY
REGISTRY_USER: $CI_REGISTRY_USER
REGISTRY_PASSWORD: $CI_REGISTRY_PASSWORD
REGISTRY_PROJECT: "/${CI_PROJECT_PATH}/"
services:
- docker:dind
before_script:
......@@ -79,3 +150,29 @@ build-docker-image:
- npx nx affected --base=HEAD~1 --target=docker-build --registry=$REGISTRY --registryProject=$REGISTRY_PROJECT --tag=$TAG --parallel=2
after_script:
- docker logout $REGISTRY
build-docker-release:
stage: packetize
extends: .distributed
rules:
- if: $CI_COMMIT_TAG
needs:
- install-dependencies
- build-release
- test-release
image: docker:git
services:
- docker:dind
before_script:
- apk update && apk add npm
- npm i -g npx
- echo "$REGISTRY_PASSWORD" | docker login -u $REGISTRY_USER --password-stdin $REGISTRY
script:
- docker build -f scripts/db/Dockerfile --target=prod -t ${REGISTRY}${REGISTRY_PROJECT}iqbberlin/personaldb-db:${CI_COMMIT_TAG} .
- docker build -f apps/api/Dockerfile --build-arg project=api -t ${REGISTRY}${REGISTRY_PROJECT}iqbberlin/personaldb-backend:${CI_COMMIT_TAG} .
- docker build -f apps/frontend/Dockerfile --build-arg project=frontend -t ${REGISTRY}${REGISTRY_PROJECT}iqbberlin/personaldb-frontend:${CI_COMMIT_TAG} .
- docker push ${REGISTRY}${REGISTRY_PROJECT}iqbberlin/personaldb-db:${CI_COMMIT_TAG}
- docker push ${REGISTRY}${REGISTRY_PROJECT}iqbberlin/personaldb-backend:${CI_COMMIT_TAG}
- docker push ${REGISTRY}${REGISTRY_PROJECT}iqbberlin/personaldb-frontend:${CI_COMMIT_TAG}
after_script:
- docker logout $REGISTRY
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment