Created
February 24, 2020 13:16
-
-
Save hongkongkiwi/599d263db1128c91cd3b4ebf7522ad32 to your computer and use it in GitHub Desktop.
gitlab-ci.yml for building a docker image and pushing to a private gitlab registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: docker:19.03.1 | |
before_script: | |
- docker info | |
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY | |
build_image: | |
stage: build | |
script: | |
- docker pull $CI_REGISTRY_IMAGE:latest || true | |
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest . | |
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA | |
- docker push $CI_REGISTRY_IMAGE:latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment