This repository has been archived by the owner on Apr 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
100 lines (86 loc) · 2.47 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
image: docker:latest
stages:
- build
- build_nginx
- push
variables:
DOCKER_BUILDKIT: 1
PHP_IMAGE: "${CI_REGISTRY_IMAGE}/php"
PHP_TMP_IMAGE: "${CI_REGISTRY_IMAGE}/php:${CI_COMMIT_SHORT_SHA}"
NGINX_IMAGE: "${CI_REGISTRY_IMAGE}/nginx"
NGINX_TMP_IMAGE: "${CI_REGISTRY_IMAGE}/nginx:${CI_COMMIT_SHORT_SHA}"
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
tmp_build_php:
stage: build
script:
- docker pull $PHP_IMAGE:latest || true
- docker pull $PHP_TMP_IMAGE || docker build --pull -t $PHP_TMP_IMAGE .
- docker push $PHP_TMP_IMAGE
only:
- branches
- tags
tmp_build_nginx:
stage: build_nginx
script:
- docker pull $NGINX_TMP_IMAGE:latest || true
- docker pull $NGINX_TMP_IMAGE || docker build --pull --build-arg php_image=$PHP_TMP_IMAGE -t $NGINX_TMP_IMAGE -f Dockerfile.nginx .
- docker push $NGINX_TMP_IMAGE
only:
- branches
- tags
push_php_branches:
stage: push
script:
- docker pull $PHP_TMP_IMAGE
- docker tag $PHP_TMP_IMAGE "$PHP_IMAGE:$CI_COMMIT_REF_NAME"
- docker push "$PHP_IMAGE:$CI_COMMIT_REF_NAME"
only:
- branches
except:
- master
push_php_tags:
stage: push
script:
- docker pull $PHP_TMP_IMAGE
- docker tag $PHP_TMP_IMAGE "$PHP_IMAGE:$CI_COMMIT_TAG"
- docker push "$PHP_IMAGE:$CI_COMMIT_TAG"
only:
- tags
push_php_latest:
stage: push
script:
- docker pull $PHP_TMP_IMAGE
- docker tag $PHP_TMP_IMAGE "$PHP_IMAGE:latest"
- docker push "$PHP_IMAGE:latest"
only:
- master
push_nginx_branches:
stage: push
script:
- docker pull $NGINX_TMP_IMAGE
- docker tag $NGINX_TMP_IMAGE "$NGINX_IMAGE:${CI_COMMIT_REF_NAME/\//-}"
- docker push "$NGINX_IMAGE:${CI_COMMIT_REF_NAME/\//-}"
only:
- branches
except:
- master
push_nginx_tags:
stage: push
script:
- docker pull $NGINX_TMP_IMAGE
- docker tag $NGINX_TMP_IMAGE "$NGINX_IMAGE:$CI_COMMIT_TAG"
- docker push "$NGINX_IMAGE:$CI_COMMIT_TAG"
only:
- tags
push_nginx_latest:
stage: push
script:
- docker pull $NGINX_TMP_IMAGE
- docker tag $NGINX_TMP_IMAGE "$NGINX_IMAGE:latest"
- docker push "$NGINX_IMAGE:latest"
only:
- master
#vim: set noet sw=4 ts=4: