-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
79 lines (69 loc) · 1.96 KB
/
.gitlab-ci.yml
File metadata and controls
79 lines (69 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
workflow:
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.(a|b|rc)?[0-9]+$/'
when: always
- when: never
# Just extract version info
version-info:
stage: .pre
image: alpine:latest
before_script: [] # Override the default docker login since we don't need it (and alpine doesn't have docker)
script:
- |
# Extract version from tag (e.g., v0.9.8 -> 0.9.8)
echo "VERSION=${CI_COMMIT_TAG#v}" >> build.env
# Extract MAJOR.MINOR version from tag name (e.g., v0.9.8 -> 0.9)
MAJOR_MINOR=$(echo ${CI_COMMIT_TAG#v} | cut -d'.' -f1,2)
echo "BRANCH_VERSION=$MAJOR_MINOR" >> build.env
artifacts:
reports:
dotenv: build.env
.service-template: &service-template
stage: build
image: docker:24.0.5-cli
services:
- docker:24.0.5-dind
needs:
- version-info
script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin registry.gitlab.com
- cd $BUILD_DIR
- >
docker build
--pull
-t $CI_REGISTRY_IMAGE/$SERVICE:$BRANCH_VERSION-latest
-f $DOCKERFILE
.
- docker tag $CI_REGISTRY_IMAGE/$SERVICE:$BRANCH_VERSION-latest $CI_REGISTRY_IMAGE/$SERVICE:$VERSION
- docker push $CI_REGISTRY_IMAGE/$SERVICE:$BRANCH_VERSION-latest
- docker push $CI_REGISTRY_IMAGE/$SERVICE:$VERSION
build:webapp:
variables:
SERVICE: app
BUILD_DIR: webapps/main
DOCKERFILE: webapp.prod.Dockerfile
<<: *service-template
build:warehouse:
variables:
SERVICE: warehouse
BUILD_DIR: webapps/warehouse
DOCKERFILE: Dockerfile
<<: *service-template
build:api:
variables:
SERVICE: api
BUILD_DIR: backend/api
DOCKERFILE: Dockerfile
<<: *service-template
build:workflow:
variables:
SERVICE: wf-sys-worker
BUILD_DIR: backend/workflow
DOCKERFILE: Dockerfile
<<: *service-template
build:print-service:
variables:
SERVICE: print-service
BUILD_DIR: backend/print-service
DOCKERFILE: Dockerfile
<<: *service-template