forked from kartevonmorgen/openfairdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
47 lines (40 loc) · 1.5 KB
/
.gitlab-ci.yml
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
image: docker:19
stages:
- pre-build
- build
services:
- docker:dind
variables:
GIT_DEPTH: 1
DOCKER_DRIVER: overlay2
BUILD_IMAGE: $CI_REGISTRY_IMAGE/build
COMMIT_IMAGE: $CI_REGISTRY_IMAGE/commit
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build:image:
stage: pre-build
script:
- docker pull $BUILD_IMAGE:$CI_COMMIT_BEFORE_SHA || true
- docker pull $BUILD_IMAGE:$CI_COMMIT_SHA || true
- docker pull $BUILD_IMAGE:latest || true
- docker build --target build --cache-from $BUILD_IMAGE:$CI_COMMIT_BEFORE_SHA --cache-from $BUILD_IMAGE:$CI_COMMIT_SHA --cache-from $BUILD_IMAGE:latest --tag $BUILD_IMAGE:$CI_COMMIT_SHA --tag $BUILD_IMAGE:latest .
- docker push $BUILD_IMAGE:$CI_COMMIT_SHA
- docker push $BUILD_IMAGE:latest
build:commit:
stage: build
script:
- docker pull $BUILD_IMAGE:$CI_COMMIT_SHA || true
- docker pull $BUILD_IMAGE:$latest || true
- docker build --cache-from $BUILD_IMAGE:$CI_COMMIT_SHA --cache-from $BUILD_IMAGE:latest --tag $COMMIT_IMAGE:$CI_COMMIT_SHA .
- docker push $COMMIT_IMAGE:$CI_COMMIT_SHA
except:
- tags
build:tag:
stage: build
script:
- docker pull $BUILD_IMAGE:$CI_COMMIT_SHA || true
- docker pull $BUILD_IMAGE:$latest || true
- docker build --cache-from $BUILD_IMAGE:$CI_COMMIT_SHA --cache-from $BUILD_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
only:
- tags