-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
174 lines (157 loc) · 4.72 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
# Variables to be set (most optional) in you CI vars
# * CI_REGISTRY_IMAGE (required) - the full url for your image name. docker.io/10up/base-php for docker, for example
# * CI_REGISTRY_USER (optional) - the user for the registry. Don't override this for gitlab unless you know what you're doing
# * CI_REGISTRY_PASSWORD (optional) - the password for the registry. Don't override this for gitlab unless you know what you're doing
# * CI_REGISTRY (optional) - the registry URL (optional). Don't override this for gitlab unless you know what you're doing
#
# The gitlab-runner must be installed with these settings in the runners: section
# config: |
# [[runners]]
# [runners.kubernetes]
# image = "ubuntu:20.04"
# privileged = true
# [[runners.kubernetes.volumes.empty_dir]]
# name = "docker-certs"
# mount_path = "/certs/client"
# medium = "Memory"
#
variables:
BUILDX_VERSION: "v0.5.1"
stages:
- build
.common:
image: docker
stage: build
services:
- docker:19-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
retry: 2
tags:
- kubernetes
before_script:
- i=0; while [ "$i" -lt 12 ]; do docker info && break; sleep 5; i=$(( i + 1 )) ; done
script:
- cd ${BASE:?}
- |
export DOCKER_TAG=${PHP_VERSION}
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build --no-cache --pull --network host --build-arg BASE_IMAGE=${CI_BASE_IMAGE:-10up/base-php}:${PHP_VERSION} --build-arg PHP_VERSION=$PHP_VERSION --tag $CI_REGISTRY_IMAGE:${DOCKER_TAG} --tag $CI_REGISTRY_IMAGE:${DOCKER_TAG}-${CI_COMMIT_SHORT_SHA} .
- docker push $CI_REGISTRY_IMAGE:${DOCKER_TAG}
- docker push $CI_REGISTRY_IMAGE:${DOCKER_TAG}-${CI_COMMIT_SHORT_SHA}
when: on_success
only:
refs:
- trunk
- feature/ubuntu
.common-ubuntu:
image: docker
stage: build
services:
- docker:19-dind
retry: 2
tags:
- buildx
variables:
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
before_script:
- i=0; while [ "$i" -lt 12 ]; do docker info && break; sleep 5; i=$(( i + 1 )) ; done
- apk add curl
- mkdir -vp ~/.docker/cli-plugins/ ~/dockercache
- curl --silent -L "https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
- chmod a+x ~/.docker/cli-plugins/docker-buildx
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker context create dindbuilder
- docker context use dindbuilder
- docker buildx create --use
- docker buildx inspect --bootstrap
script:
- |
export DOCKER_TAG=${PHP_VERSION}
- docker buildx build --no-cache --pull --build-arg BASE_IMAGE=${CI_BASE_IMAGE:-10up/base-php}:${PHP_VERSION}-ubuntu --build-arg PHP_VERSION=$PHP_VERSION --tag $CI_REGISTRY_IMAGE:${DOCKER_TAG}-ubuntu --tag $CI_REGISTRY_IMAGE:${DOCKER_TAG}-${CI_COMMIT_SHORT_SHA}-ubuntu --platform ${PLATFORMS} --push .
when: on_success
only:
refs:
- trunk
- feature/ubuntu
# centos versions
PHP 5.6:
variables:
PHP_VERSION: '5.6'
BASE: 'centos7'
extends: .common
PHP 7.0:
variables:
PHP_VERSION: '7.0'
BASE: 'centos7'
extends: .common
PHP 7.1:
stage: build
variables:
PHP_VERSION: '7.1'
BASE: 'centos7'
extends: .common
PHP 7.2:
variables:
PHP_VERSION: '7.2'
BASE: 'centos8'
extends: .common
PHP 7.3:
variables:
PHP_VERSION: '7.3'
BASE: 'centos8'
extends: .common
PHP 7.4:
variables:
PHP_VERSION: '7.4'
BASE: 'centos8'
extends: .common
PHP 8.0:
variables:
PHP_VERSION: '8.0'
BASE: 'centos8'
extends: .common
# ubuntu versions
PHP 5.6-ubuntu:
variables:
PHP_VERSION: '5.6'
PLATFORMS: 'linux/amd64,linux/arm64'
extends: .common-ubuntu
PHP 7.0-ubuntu:
variables:
PHP_VERSION: '7.0'
PLATFORMS: 'linux/amd64,linux/arm64'
extends: .common-ubuntu
PHP 7.1-ubuntu:
stage: build
variables:
PHP_VERSION: '7.1'
PLATFORMS: 'linux/amd64,linux/arm64'
extends: .common-ubuntu
PHP 7.2-ubuntu:
variables:
PHP_VERSION: '7.2'
PLATFORMS: 'linux/amd64,linux/arm64'
extends: .common-ubuntu
PHP 7.3-ubuntu:
variables:
PHP_VERSION: '7.3'
PLATFORMS: 'linux/amd64,linux/arm64'
extends: .common-ubuntu
PHP 7.4-ubuntu:
variables:
PHP_VERSION: '7.4'
PLATFORMS: 'linux/amd64,linux/arm64'
extends: .common-ubuntu
PHP 8.0-ubuntu:
variables:
PHP_VERSION: '8.0'
PLATFORMS: 'linux/amd64,linux/arm64'
extends: .common-ubuntu