-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
47 lines (43 loc) · 1.59 KB
/
.gitlab-ci.yml
File metadata and controls
47 lines (43 loc) · 1.59 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
# will never run on a git push or merge request event.
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- when: always
variables:
DOCKER_TLS_CERTDIR: "/certs"
FF_NETWORK_PER_BUILD: "true"
FULL_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID
POSTGRES_DB: cstacks
POSTGRES_USER: cstacks
POSTGRES_PASSWORD: cstacks
REDIS_HOST: redis
DATABASE_URL: "postgres://cstacks:cstacks@postgres/cstacks"
CS_MINOR_VERSION: "9.3"
CS_MAJOR_VERSION: "9"
default:
image: docker:25
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY --username $CI_REGISTRY_USER --password-stdin
after_script:
- docker logout $CI_REGISTRY
- docker logout
stages:
- build
build:
stage: build
services:
- docker:25-dind
- postgres:16
- redis:alpine
script:
- "docker build --network=host --add-host=redis:$(getent hosts redis | awk '{ print $1 }') --add-host=postgres:$(getent hosts postgres | awk '{ print $1 }') --cache-from $CI_REGISTRY_IMAGE:$CS_MAJOR_VERSION --progress plain --build-arg db_url=$DATABASE_URL --build-arg redis_host=$REDIS_HOST -t $FULL_IMAGE ."
- "docker tag $FULL_IMAGE $CI_REGISTRY_IMAGE:$CS_MINOR_VERSION"
- "docker tag $FULL_IMAGE $CI_REGISTRY_IMAGE:$CS_MAJOR_VERSION"
- "docker tag $FULL_IMAGE $CI_REGISTRY_IMAGE:latest"
- "docker push $FULL_IMAGE"
- "docker push $CI_REGISTRY_IMAGE:$CS_MINOR_VERSION"
- "docker push $CI_REGISTRY_IMAGE:$CS_MAJOR_VERSION"
- "docker push $CI_REGISTRY_IMAGE:latest"