-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
108 lines (100 loc) · 2.52 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
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
101
102
103
104
105
106
107
108
image: docker:stable
include:
- project: divio/infra/gitlab-pipelines
ref: master
file: base/.gitlab-ci.yml
variables:
BUILDX_VERSION: v0.10.4
BUILDX_ARCH: linux-amd64
PLATFORMS: linux/arm64/v8,linux/amd64
PUBLIC_REPOSITORY: divio/base
BUILDX_URL: https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.${BUILDX_ARCH}
linting:
image: divio/lint
stage: qa
needs: []
script:
- find .
-type f
-name Dockerfile
-not -path './EOL-*'
-print0 | xargs -0 -I %
sh -c 'LINT_FILE_DOCKER=% /bin/lint --check --run=docker'
.build:
stage: build
needs: []
before_script:
- mkdir -p /usr/libexec/docker/cli-plugins
- wget -q -O /usr/libexec/docker/cli-plugins/docker-buildx ${BUILDX_URL}
- chmod +x /usr/libexec/docker/cli-plugins/docker-buildx
- docker buildx version
- docker buildx create --use
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
script:
- >
docker buildx build
--platform ${PLATFORMS}
--build-arg TARGET=${TARGET}
--tag ${IMAGE_NAME}
--push
${CI_COMMIT_TAG#*-}
only:
- tags
build-dev:
extends: .build
variables:
TARGET: dev
IMAGE_NAME: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}-dev
build-prod:
extends: .build
variables:
TARGET: prod
IMAGE_NAME: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
test-dev:
stage: test
needs:
- build-dev
before_script:
- apk add python3
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
script:
- >
./build.py
--repo ${CI_REGISTRY_IMAGE}
--target=dev
--tag ${CI_COMMIT_TAG}
test
only:
- tags
push:
stage: release
needs:
- build-prod
- test-dev
image:
name: ananace/skopeo
entrypoint: [""]
variables:
GIT_STRATEGY: none
IMAGE_NAME: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
SRC_REGISTRY_CREDS: ${CI_REGISTRY_USER}:${CI_JOB_TOKEN}
DST_REGISTRY_CREDS: ${DOCKER_HUB_USER}:${DOCKER_HUB_TOKEN}
script:
- >
/skopeo
copy
--multi-arch all
--src-creds=${SRC_REGISTRY_CREDS}
--dest-creds=${DST_REGISTRY_CREDS}
docker://${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}-dev
docker://${PUBLIC_REPOSITORY}:${CI_COMMIT_TAG}-dev
- >
/skopeo
copy
--multi-arch all
--src-creds=${SRC_REGISTRY_CREDS}
--dest-creds=${DST_REGISTRY_CREDS}
docker://${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
docker://${PUBLIC_REPOSITORY}:${CI_COMMIT_TAG}
only:
- tags