-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
64 lines (54 loc) · 2.02 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
variables:
DOCKER_DRIVER: overlay2
DOCKER_BASH_IMAGE_LATEST: "$CI_REGISTRY_IMAGE/common/docker-bash:latest"
DOCKER_BASH_IMAGE_SHA: "$CI_REGISTRY_IMAGE/common/docker-bash:$CI_COMMIT_SHA"
BUILD_IMAGE_LATEST: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/build:latest"
BUILD_IMAGE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/build:$CI_COMMIT_SHA"
BUILD_IMAGE_BEFORE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/build:$CI_COMMIT_BEFORE_SHA"
DIST_IMAGE_LATEST: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/dist:latest"
DIST_IMAGE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/dist:$CI_COMMIT_SHA"
DIST_IMAGE_BEFORE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/dist:$CI_COMMIT_BEFORE_SHA"
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- mkdir empty_dir
image: $DOCKER_BASH_IMAGE_LATEST
services:
- docker:dind
stages:
- build:dependencies
- build:application
- pack
build:docker-bash:
stage: build:dependencies
image: docker:stable
tags:
- docker
only:
variables:
- $BUILD_DOCKER_BASH == "true"
script:
- docker pull $DOCKER_BASH_IMAGE_LATEST || true
- docker build --pull -f ci/docker-bash.dockerfile --cache-from $DOCKER_BASH_IMAGE_LATEST --tag $DOCKER_BASH_IMAGE_SHA --tag $DOCKER_BASH_IMAGE_LATEST empty_dir
- docker push $DOCKER_BASH_IMAGE_LATEST
- docker push $DOCKER_BASH_IMAGE_SHA
build:balancer:
stage: build:application
tags:
- docker
except:
- schedules
script:
- bash ci/build-image.sh -f docker/build.dockerfile -c $BUILD_IMAGE_BEFORE_SHA -c $BUILD_IMAGE_SHA -n $BUILD_IMAGE_SHA -n $BUILD_IMAGE_LATEST .
- bash ci/extract-from-image.sh $BUILD_IMAGE_SHA /tmp/simple-redirect-loadbalancer/build build
artifacts:
paths:
- build
expire_in: 3 months
pack:dist:
stage: pack
tags:
- docker
except:
- schedules
script:
- bash ci/build-image.sh -f docker/dist.dockerfile -a BUILD_IMAGE=$BUILD_IMAGE_SHA -c $DIST_IMAGE_BEFORE_SHA -c $DIST_IMAGE_SHA -n $DIST_IMAGE_SHA -n $DIST_IMAGE_LATEST empty_dir