image: docker:latest stages: - test - build variables: VERSION: latest AUTO_VERSION: ${CI_COMMIT_TAG:-latest} CACHETAG: build DOCKER_REGISTRY: registry.leenooks.net DOCKER_HOST: tcp://${DOCKER_REGISTRY}-leenooks-ci-docker:2375 services: - ${DOCKER_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_PROJECT_PATH ${CI_PROJECT_PATH} CI_COMMIT_TAG ${CI_COMMIT_TAG} CI_COMMIT_REF_NAME ${CI_COMMIT_REF_NAME}" - echo "CI_REGISTRY ${CI_REGISTRY} CI_REGISTRY_IMAGE ${CI_REGISTRY_IMAGE} CI ${CI}" - echo "AUTO_VERSION ${AUTO_VERSION}" test: stage: test script: - cat /etc/hosts - env|sort - docker build -t ${CI_REGISTRY_IMAGE}:${VERSION} . - docker images only: - debug build: stage: build script: - chmod 500 init - 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: - master