Updated CI to take advantage of cache building

This commit is contained in:
Deon George 2017-12-13 22:01:01 +11:00
parent fd6c550269
commit fee2424f68

View File

@ -6,7 +6,7 @@ stages:
variables: variables:
VERSION: 7.1-fpm-plus VERSION: 7.1-fpm-plus
DOCKER_IMAGE: leenooks/php CACHETAG: build
DOCKER_REGISTRY: registry.leenooks.net DOCKER_REGISTRY: registry.leenooks.net
DOCKER_HOST: tcp://${DOCKER_REGISTRY}-leenooks-ci-docker:2375 DOCKER_HOST: tcp://${DOCKER_REGISTRY}-leenooks-ci-docker:2375
@ -23,7 +23,7 @@ test:
script: script:
- cat /etc/hosts - cat /etc/hosts
- env|sort - env|sort
- docker build -t ${DOCKER_IMAGE}:${VERSION} . - docker build -t ${CI_REGISTRY_IMAGE}:${VERSION} .
- docker images - docker images
only: only:
- debug - debug
@ -31,9 +31,10 @@ test:
build: build:
stage: build stage: build
script: script:
- docker build -t ${DOCKER_IMAGE}:${VERSION} . - docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG} || true
- docker tag ${DOCKER_IMAGE}:${VERSION} ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${VERSION} - docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} .
- docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${VERSION} - docker push ${CI_REGISTRY_IMAGE}:${VERSION}
- docker push ${CI_REGISTRY_IMAGE}:${CACHETAG}
tags: tags:
- docker - docker
only: only: