@@ -24,6 +24,13 @@ stages:
24
24
- php composer.phar install
25
25
- vendor/bin/phpunit --coverage-text --colors=never
26
26
27
+ .docker :
28
+ image : docker:18.09.7
29
+ services :
30
+ - docker:18.09.7-dind
31
+ before_script :
32
+ - echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
33
+
27
34
test:7.3 :
28
35
extends : .tests
29
36
image : php:7.3
@@ -51,12 +58,11 @@ build_package:
51
58
- README.md
52
59
53
60
Docker Build :
54
- image : docker:18
61
+ extends : . docker
55
62
stage : build_image
56
63
dependencies :
57
64
- build_package
58
65
script :
59
- - echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
60
66
# fetches the latest image (not failing if image is not found)
61
67
- docker pull $CI_REGISTRY_IMAGE:latest || true
62
68
# builds the project and passes vcs vars for LABEL
@@ -76,7 +82,7 @@ Docker Build:
76
82
77
83
# Here, the goal is to tag the "master" branch as "latest"
78
84
Push Docker latest :
79
- image : docker:18
85
+ extends : . docker
80
86
variables :
81
87
# We are just playing with Docker here.
82
88
# We do not need GitLab to clone the source code.
@@ -86,7 +92,6 @@ Push Docker latest:
86
92
# Only "master" should be tagged "latest"
87
93
- master
88
94
script :
89
- - echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
90
95
# Because we have no guarantee that this job will be picked up by the same runner
91
96
# that built the image in the previous step, we pull it again locally
92
97
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
@@ -98,7 +103,7 @@ Push Docker latest:
98
103
# Finally, the goal here is to Docker tag any Git tag
99
104
# GitLab will start a new pipeline everytime a Git tag is created, which is pretty awesome
100
105
Push Docker tag :
101
- image : docker:18
106
+ extends : . docker
102
107
variables :
103
108
# Again, we do not need the source code here. Just playing with Docker.
104
109
GIT_STRATEGY : none
@@ -107,7 +112,6 @@ Push Docker tag:
107
112
# We want this job to be run on tags only.
108
113
- tags
109
114
script :
110
- - echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
111
115
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
112
116
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
113
117
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
0 commit comments