Skip to content

Commit a0eecb8

Browse files
committed
Fix Docker build
1 parent f7facdf commit a0eecb8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.gitlab-ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ stages:
2424
- php composer.phar install
2525
- vendor/bin/phpunit --coverage-text --colors=never
2626

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+
2734
test:7.3:
2835
extends: .tests
2936
image: php:7.3
@@ -51,12 +58,11 @@ build_package:
5158
- README.md
5259

5360
Docker Build:
54-
image: docker:18
61+
extends: .docker
5562
stage: build_image
5663
dependencies:
5764
- build_package
5865
script:
59-
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
6066
# fetches the latest image (not failing if image is not found)
6167
- docker pull $CI_REGISTRY_IMAGE:latest || true
6268
# builds the project and passes vcs vars for LABEL
@@ -76,7 +82,7 @@ Docker Build:
7682

7783
# Here, the goal is to tag the "master" branch as "latest"
7884
Push Docker latest:
79-
image: docker:18
85+
extends: .docker
8086
variables:
8187
# We are just playing with Docker here.
8288
# We do not need GitLab to clone the source code.
@@ -86,7 +92,6 @@ Push Docker latest:
8692
# Only "master" should be tagged "latest"
8793
- master
8894
script:
89-
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
9095
# Because we have no guarantee that this job will be picked up by the same runner
9196
# that built the image in the previous step, we pull it again locally
9297
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
@@ -98,7 +103,7 @@ Push Docker latest:
98103
# Finally, the goal here is to Docker tag any Git tag
99104
# GitLab will start a new pipeline everytime a Git tag is created, which is pretty awesome
100105
Push Docker tag:
101-
image: docker:18
106+
extends: .docker
102107
variables:
103108
# Again, we do not need the source code here. Just playing with Docker.
104109
GIT_STRATEGY: none
@@ -107,7 +112,6 @@ Push Docker tag:
107112
# We want this job to be run on tags only.
108113
- tags
109114
script:
110-
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
111115
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
112116
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
113117
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME

0 commit comments

Comments
 (0)