blob: c836f0272e14dd12c4ba376cb274e25ef53e04f7 (
plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# When using dind, it's wise to use the overlayfs driver for
# improved performance.
variables:
DOCKER_DRIVER: overlay2
MAJOR: 3
TMP_IMAGE: $CI_REGISTRY_IMAGE/tmp:$CI_COMMIT_SHA
include:
- template: Container-Scanning.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
- template: Jobs/Code-Quality.gitlab-ci.yml
- local: .gitlab/test.yml
- local: .gitlab/release.yml
stages:
- build
- test
- tag
- release
default:
image:
name: $TMP_IMAGE
entrypoint: [""]
tags: [gitlab-org]
build commit:
image: docker:stable
stage: build
tags: [gitlab-org-docker]
services:
- docker:stable-dind
script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $TMP_IMAGE .
- docker image inspect $TMP_IMAGE --format='{{.Size}}'
- docker push $TMP_IMAGE
container_scanning:
variables:
CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE/tmp # only predefined variables are parameter-expanded (no $TMP_IMAGE)
.docker_tag:
image: docker:stable
stage: tag
tags: [gitlab-org-docker]
services:
- docker:stable-dind
script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- export SOURCE_IMAGE=$TMP_IMAGE
- export TARGET_IMAGE=$CI_REGISTRY_IMAGE:${IMAGE_TAG:-$CI_JOB_NAME}
- |
if [ -z "$DOTENV" ]; then
docker pull $SOURCE_IMAGE
docker tag $SOURCE_IMAGE $TARGET_IMAGE
else
./bin/docker-dotenv
fi
- docker push $TARGET_IMAGE
branch:
extends: .docker_tag
variables:
IMAGE_TAG: $CI_COMMIT_REF_SLUG
only:
- branches
except:
- master
edge:
extends: .docker_tag
variables:
IMAGE_TAG: edge
only:
- master
version:
extends: .docker_tag
before_script:
- export IMAGE_TAG=${CI_COMMIT_TAG/v/}
- echo "Checking that $CI_COMMIT_TAG is last in the changelog"
- test "$(grep '^## v' CHANGELOG.md |head -n 1)" = "## $CI_COMMIT_TAG"
only:
- tags
when: manual
allow_failure: false
code_quality:
before_script:
- rm .rubocop.yml
license_scanning:
image:
name: $TMP_IMAGE
services:
- docker:stable-dind
|