forked from akuity/guestbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
26 lines (22 loc) · 951 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
GIT_COMMIT_COUNT=$(shell printf '%05d' `git rev-list --count HEAD`)
GIT_COMMIT_TIME=$(shell git show -s --date=format:'%Y%m%d-%H%M' --format='%cd')
GIT_SHA=$(shell git rev-parse --short HEAD)
IMAGE_TAG?=${GIT_COMMIT_COUNT}-${GIT_SHA}
IMAGE_REPOSITORY?=ghcr.io/kustomize-everything/guestbook
.PHONY: build
build:
CGO_ENABLED=0 go build -v -o build/guestbook ./main.go
.PHONY: image
image: build
docker build -t ${IMAGE_REPOSITORY}:${IMAGE_TAG} .
# push latest image with multiple tags
# only push linux/amd64 so we don't need to deal with multi-arch images
# echos the image as an output for use with github actions
.PHONY: push-latest
push-latest:
docker buildx build --push --platform=linux/amd64 . \
-t ${IMAGE_REPOSITORY}:${IMAGE_TAG} \
-t ${IMAGE_REPOSITORY}:${GIT_COMMIT_COUNT} \
-t ${IMAGE_REPOSITORY}:${GIT_COMMIT_TIME}-${GIT_SHA} \
-t ${IMAGE_REPOSITORY}:latest
echo "::set-output name=image::${IMAGE_REPOSITORY}:${IMAGE_TAG}"