From 750e90bc2a486c3580fdd89fd6390c36781f55c3 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 20 Mar 2018 21:58:45 +1100 Subject: [PATCH] Updated .gitlab-ci --- .gitlab-ci.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b8b8e6a..eec0f60 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,24 +6,23 @@ stages: variables: VERSION: 7-8.1 - DOCKER_IMAGE: leenooks/ci-tsm - DOCKER_REGISTRY: registry.leenooks.net - DOCKER_HOST: tcp://${DOCKER_REGISTRY}-leenooks-ci-docker:2375 + CACHETAG: build + DOCKER_HOST: tcp://${CI_REGISTRY}-leenooks-ci-docker:2375 services: -- ${DOCKER_REGISTRY}/leenooks/ci-docker:dind +- ${CI_REGISTRY}/leenooks/ci-docker:dind before_script: - docker info - docker version -- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN ${DOCKER_REGISTRY} +- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin test: stage: test script: - cat /etc/hosts - env|sort - - docker build -t ${DOCKER_IMAGE}:${VERSION} . + - docker build -t ${CI_REGISTRY_IMAGE}:${VERSION} . - docker images only: - debug @@ -31,9 +30,11 @@ test: build: stage: build script: - - docker build -t ${DOCKER_IMAGE}:${VERSION} . - - docker tag ${DOCKER_IMAGE}:${VERSION} ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${VERSION} - - docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${VERSION} + - if [ -f init ]; then chmod 500 init; fi + - docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG} || true + - docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} . + - docker push ${CI_REGISTRY_IMAGE}:${VERSION} + - docker push ${CI_REGISTRY_IMAGE}:${CACHETAG} tags: - docker only: