Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: retag when possible #188

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python-minimal/.envfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Dockerfile
requirements.txt
environment.yml
18 changes: 13 additions & 5 deletions python-minimal/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ variables:
GIT_SSL_NO_VERIFY: "true"
GIT_LFS_SKIP_SMUDGE: 1
DOCKER_BUILDKIT: 1
BUILDX_VERSION: "v0.11.0"
BUILDX_ARCH: "linux-amd64"


stages:
- build

image_build:
stage: build
image: docker:stable
before_script:
image: docker:stable-git
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN http://$CI_REGISTRY
- wget -O /usr/bin/docker-buildx
https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.${BUILDX_ARCH}
- chmod +x /usr/bin/docker-buildx
script: |
CI_COMMIT_SHA_7=$(echo $CI_COMMIT_SHA | cut -c1-7)
docker build --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA_7 .
docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA_7
LAST_CHANGE=$(git log -n 1 --pretty=format:%H -- $(cat .envfiles) | cut -c1-7)
CURRENT_COMMIT=$(git rev-parse HEAD | cut -c1-7)
docker-buildx imagetools create $CI_REGISTRY_IMAGE:$LAST_CHANGE --tag $CI_REGISTRY_IMAGE:$CURRENT_COMMIT || \
docker-buildx build --push --tag $CI_REGISTRY_IMAGE:$CURRENT_COMMIT .