Skip to content

Instantly share code, notes, and snippets.

@justerror
Last active July 29, 2021 08:58
Show Gist options
  • Save justerror/bf64ce3d8f693fa587319185c3848039 to your computer and use it in GitHub Desktop.
Save justerror/bf64ce3d8f693fa587319185c3848039 to your computer and use it in GitHub Desktop.
Tagging Docker images with commit hash
NAME := your-registry.com/username/project-name
TAG := $$(git log -1 --pretty=%h)
IMG := ${NAME}:${TAG}
LATEST := ${NAME}:latest
build:
@docker build . -t ${IMG} --progress=plain
@docker tag ${IMG} ${LATEST}
push:
@docker push ${NAME}
login:
@docker login -u ${DOCKER_USER} -p ${DOCKER_PASS} your-registry.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment