Skip to content

Instantly share code, notes, and snippets.

@esys
Last active October 28, 2020 14:07
Show Gist options
  • Save esys/cd0fabd23f6d6c8eac5b4bdf4735b4e2 to your computer and use it in GitHub Desktop.
Save esys/cd0fabd23f6d6c8eac5b4bdf4735b4e2 to your computer and use it in GitHub Desktop.
gitlab with build and push builder stage
stages:
- build
- test
- deploy
variables:
# disable Docker TLS validation
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://localhost:2375"
services:
- docker:stable-dind
docker-build:
image: docker:stable
stage: build
script:
- docker pull my-registry/hello-builder:latest || true
- docker pull my-registry/hello:latest || true
- docker build --cache-from my-registry/hello-builder:latest --target builder -t hello-builder:latest .
- docker build --cache-from my-registry/hello:latest --cache-from my-registry/hello-builder:latest -t hello:latest .
- docker tag hello-builder:latest my-registry/hello-builder:latest
- docker tag hello:latest my-registry/hello:${CI_COMMIT_SHORT_SHA}
- docker tag hello:latest my-registry/hello:latest
- docker push my-registry/hello-builder:latest
- docker push my-registry/hello:${CI_COMMIT_SHORT_SHA}
- docker push my-registry/hello:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment