Last active
May 28, 2021 11:28
-
-
Save rosscdh/88244fcb3fc75b6ebb5d399640178e2b to your computer and use it in GitHub Desktop.
docker makefile
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
| .PHONY: all build login push run | |
| NAME := rosscdh/my-project | |
| TAG := $$(git log -1 --pretty=%h) | |
| VERSION := ${NAME}:${TAG} | |
| LATEST := ${NAME}:latest | |
| BUILD_REPO_ORIGIN=$$(git config --get remote.origin.url) | |
| BUILD_COMMIT_SHA1:=$$(git rev-parse --short HEAD) | |
| BUILD_COMMIT_DATE:=$$(git log -1 --date=short --pretty=format:%ct) | |
| BUILD_BRANCH:=$$(git symbolic-ref --short HEAD) | |
| BUILD_DATE:=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| export | |
| all: build login push | |
| build: | |
| docker build -t ${LATEST} -t ${VERSION} \ | |
| --build-arg BUILD_COMMIT_SHA1=${BUILD_COMMIT_SHA1} \ | |
| --build-arg BUILD_COMMIT_DATE=${BUILD_COMMIT_DATE} \ | |
| --build-arg BUILD_BRANCH=${BUILD_BRANCH} \ | |
| --build-arg BUILD_DATE=${BUILD_DATE} \ | |
| --build-arg BUILD_REPO_ORIGIN=${BUILD_REPO_ORIGIN} \ | |
| . | |
| push: | |
| docker push ${TAG} | |
| docker push ${LATEST} | |
| run: | |
| docker run -p8090:8080 ${LATEST} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and the Dockerfile should contain the following to make the build info part of the env and easily displayable