Last active
June 13, 2023 15:42
-
-
Save santiagon610/45202dedeb99a9121e6403738750007d to your computer and use it in GitHub Desktop.
Builds Docker images and pushes them to the Gitlab internal registry
This file contains hidden or 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
| stages: | |
| - build | |
| - deploy | |
| - tag | |
| default: | |
| tags: | |
| - kubernetes | |
| variables: | |
| DOCKER_DRIVER: overlay2 | |
| build-image: | |
| stage: build | |
| image: docker:dind | |
| services: | |
| - docker:dind | |
| script: | |
| - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY | |
| - docker build -t $CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_SHORT_SHA . | |
| push-to-container-registry: | |
| stage: deploy | |
| image: docker:dind | |
| services: | |
| - docker:dind | |
| script: | |
| - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY | |
| - docker push $CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_SHORT_SHA | |
| skopeo-apply-latest-tag: | |
| stage: tag | |
| image: | |
| name: quay.io/skopeo/stable:latest | |
| entrypoint: ["/bin/sh", "-c"] | |
| script: | |
| - skopeo login -u $CI_REGISTRY_USER -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY | |
| - skopeo copy docker://$CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_SHORT_SHA docker://$CI_REGISTRY/$CI_PROJECT_PATH:latest | |
| only: | |
| - main | |
| - master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment