-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
78 lines (73 loc) · 2.5 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
stages:
- build
- deploy
variables:
VARNISH_STABLE: "6.0"
VARNISH_LATEST: "7.2"
services:
- docker:dind
image: docker:20
before_script:
- apk add --no-cache w3m curl jq gawk grep bash
- find . -name "*.sh" -print0 | xargs -0 -r -n1 bash -n
- export TIMESTAMP="$(date +%s)"
- export VARNISH_PATCH="$(w3m -dump https://github.com/varnishcache/varnish-cache/tags | grep -i "varnish-${VARNISH_MINOR}" | head -n1 | cut -d '-' -f 2)"
- export VARNISH_MAJOR="$(echo "${VARNISH_PATCH}" | cut -d . -f 1)"
build:docker:
stage: build
script:
- >
docker build
--no-cache
--pull
--build-arg VARNISH_VERSION="${VARNISH_PATCH}"
--build-arg ALPINE_VERSION="${ALPINE_VERSION}"
--tag "${IMAGE_NAME}:latest"
--tag "${IMAGE_NAME}:latest-${TIMESTAMP}"
--file "${CI_PROJECT_DIR}/Dockerfile"
"${CI_PROJECT_DIR}"
except:
- master
parallel:
matrix:
- VARNISH_MINOR: [ "7.1", "7.2" ]
ALPINE_VERSION: [ "3.16" ]
IMAGE_NAME: [ "hermsi/alpine-varnish" ]
- VARNISH_MINOR: [ "6.0" ]
ALPINE_VERSION: [ "3.10" ]
IMAGE_NAME: [ "hermsi/alpine-varnish" ]
deploy:docker:
stage: deploy
script:
- >
docker build
--no-cache
--pull
--build-arg VARNISH_VERSION="${VARNISH_PATCH}"
--build-arg ALPINE_VERSION="${ALPINE_VERSION}"
--tag "${IMAGE_NAME}:${VARNISH_MAJOR}"
--tag "${IMAGE_NAME}:${VARNISH_MINOR}"
--tag "${IMAGE_NAME}:${VARNISH_PATCH}"
--tag "${IMAGE_NAME}:stable"
--tag "${IMAGE_NAME}:latest"
--tag "${IMAGE_NAME}:latest-${TIMESTAMP}"
--file "${CI_PROJECT_DIR}/Dockerfile"
"${CI_PROJECT_DIR}"
- >
mkdir -p "${HOME}/.docker" &&
mv "${DOCKER_CONFIG_JSON}" "${HOME}/.docker/config.json" &&
chmod 0600 "${HOME}/.docker/config.json"
- docker push "${IMAGE_NAME}:${VARNISH_MINOR}"
- docker push "${IMAGE_NAME}:${VARNISH_PATCH}"
- if [ "${VARNISH_MINOR}" == "${VARNISH_LATEST}" ]; then docker push "${IMAGE_NAME}:latest" && docker push "${IMAGE_NAME}:latest-${TIMESTAMP}"; fi
- if [ "${VARNISH_MINOR}" == "${VARNISH_STABLE}" ]; then docker push "${IMAGE_NAME}:stable"; fi
only:
- master
parallel:
matrix:
- VARNISH_MINOR: [ "7.1", "7.2" ]
ALPINE_VERSION: [ "3.16" ]
IMAGE_NAME: [ "hermsi/alpine-varnish", "quay.io/hermsi1337/alpine-varnish" ]
- VARNISH_MINOR: [ "6.0" ]
ALPINE_VERSION: [ "3.10" ]
IMAGE_NAME: [ "hermsi/alpine-varnish", "quay.io/hermsi1337/alpine-varnish" ]