Commit c6096148 authored by svwolter's avatar svwolter
Browse files

Add GitLab CI/CD configuration file

parent 2b117ed7
image: node:lts-alpine
stages:
- setup
- build
- test
- packetize
- deploy
install-dependencies:
stage: setup
interruptible: true
only:
- main
- merge_requests
cache:
key:
files:
- package-lock.json
paths:
- node_modules
- .npm/
script:
- npm ci --cache .npm
artifacts:
paths:
- node_modules
.distributed:
interruptible: true
only:
- main
- merge_requests
needs:
- install-dependencies
artifacts:
paths:
- node_modules/.cache/nx
build-app:
stage: build
extends: .distributed
script:
- apk update && apk add git
- npx nx affected --base=HEAD~1 --target=build --parallel=3
artifacts:
paths:
- dist
test-app:
stage: test
extends: .distributed
script:
- apk update && apk add git
- npx nx affected --base=HEAD~1 --target=test --parallel=2
build-docker-image:
stage: packetize
extends: .distributed
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:
- apk update && apk add npm
- npm i -g npx
- export TAG=$(git rev-parse --short HEAD)
- echo "$REGISTRY_PASSWORD" | docker login -u $REGISTRY_USER --password-stdin $REGISTRY
script:
- npx nx affected --base=HEAD~1 --target=docker-build --registry=$REGISTRY --registryProject=$REGISTRY_PROJECT --tag=$TAG --parallel=2
after_script:
- docker logout $REGISTRY
......@@ -50,6 +50,20 @@
"jestConfig": "apps/api/jest.config.js",
"passWithNoTests": true
}
},
"docker-build": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "docker login {args.registry}",
"forwardAllArgs": false
},
"docker build -f apps/api/Dockerfile --build-arg project=api -t {args.registry}{args.registryProject}iqbberlin/personaldb-backend:{args.tag} .",
"docker push {args.registry}{args.registryProject}iqbberlin/personaldb-backend:{args.tag}"
],
"parallel": false
}
}
}
},
......@@ -173,6 +187,20 @@
"jestConfig": "apps/frontend/jest.config.js",
"passWithNoTests": true
}
},
"docker-build": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "docker login {args.registry}",
"forwardAllArgs": false
},
"docker build -f apps/frontend/Dockerfile --build-arg project=frontend -t {args.registry}{args.registryProject}iqbberlin/personaldb-frontend:{args.tag} .",
"docker push {args.registry}{args.registryProject}iqbberlin/personaldb-frontend:{args.tag}"
],
"parallel": false
}
}
},
"tags": []
......
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