-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
69 lines (63 loc) · 2.82 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
65
66
67
68
stages:
# NOTE: Build and test are one stage to prevent the pipeline from pushing
# inoperational images to the registry. Besides it should be more efficient
# As the images doesn't need to be pushed and fetched again.
- build_and_test
- update_latest
# Generic variables, here as those in *docker_jobs_common will be overwritten.
variables:
# These variables are used in the scripts.
IMAGE_NAME: $CI_REGISTRY/$CI_PROJECT_PATH
IMAGE_TAG_BASE: $CI_COMMIT_REF_NAME
# These are required to allow communication with the DIND container.
DOCKER_HOST: tcp://dockerhost:2375
DOCKER_TLS_CERTDIR: ""
# Generic code for jobs executing docker commands.
.docker_jobs_common: &docker_jobs_common
rules:
- changes:
paths:
- source/**/*
- .gitlab-ci.yml
- if: '$CI_COMMIT_TAG'
image: $RUNNER_DOCKER_IMAGE
services:
- name: $RUNNER_DIND_IMAGE
alias: dockerhost
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build_and_test_energy_service_generics:
<<: *docker_jobs_common
stage: build_and_test
rules:
- if: '$CI_COMMIT_TAG'
script:
- sh build-docker-images.sh $IMAGE_TAG_BASE
# Once all versions of the image are known to be working, push those.
- docker image tag energy-service-generics:${IMAGE_TAG_BASE} $IMAGE_NAME:${IMAGE_TAG_BASE}
- docker image tag energy-service-generics:${IMAGE_TAG_BASE}-service $IMAGE_NAME:${IMAGE_TAG_BASE}-service
- docker image tag energy-service-generics:${IMAGE_TAG_BASE}-pandas $IMAGE_NAME:${IMAGE_TAG_BASE}-pandas
- docker image tag energy-service-generics:${IMAGE_TAG_BASE}-service-pandas $IMAGE_NAME:${IMAGE_TAG_BASE}-service-pandas
- docker push $IMAGE_NAME:${IMAGE_TAG_BASE}
- docker push $IMAGE_NAME:${IMAGE_TAG_BASE}-service
- docker push $IMAGE_NAME:${IMAGE_TAG_BASE}-pandas
- docker push $IMAGE_NAME:${IMAGE_TAG_BASE}-service-pandas
update_latest_energy_service_generics:
<<: *docker_jobs_common
stage: update_latest
rules:
- if: '$CI_COMMIT_TAG'
script:
# Tag all previously images as latest if they got a git tag.
- docker pull $IMAGE_NAME:${IMAGE_TAG_BASE}
- docker pull $IMAGE_NAME:${IMAGE_TAG_BASE}-service
- docker pull $IMAGE_NAME:${IMAGE_TAG_BASE}-pandas
- docker pull $IMAGE_NAME:${IMAGE_TAG_BASE}-service-pandas
- docker image tag $IMAGE_NAME:${IMAGE_TAG_BASE} $IMAGE_NAME:latest
- docker image tag $IMAGE_NAME:${IMAGE_TAG_BASE}-service $IMAGE_NAME:latest-service
- docker image tag $IMAGE_NAME:${IMAGE_TAG_BASE}-pandas $IMAGE_NAME:latest-pandas
- docker image tag $IMAGE_NAME:${IMAGE_TAG_BASE}-service-pandas $IMAGE_NAME:latest-service-pandas
- docker push $IMAGE_NAME:latest
- docker push $IMAGE_NAME:latest-service
- docker push $IMAGE_NAME:latest-pandas
- docker push $IMAGE_NAME:latest-service-pandas