-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
34 lines (26 loc) · 845 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
27
28
29
30
31
32
33
34
.PHONY: tidy build test
ifdef VERSION
VERSION=${VERSION}
else
VERSION=$(shell git describe --always)
endif
GITCOMMIT=$(shell git rev-parse HEAD)
BUILDTIME=${shell date +%Y-%m-%dT%I:%M:%S}
LDFLAGS="-X github.com/narasux/goblog/pkg/version.Version=${VERSION} \
-X github.com/narasux/goblog/pkg/version.GitCommit=${GITCOMMIT} \
-X github.com/narasux/goblog/pkg/version.BuildTime=${BUILDTIME}"
# go mod tidy
tidy:
go mod tidy
# build executable binary
build: tidy
CGO_ENABLED=0 go build -ldflags ${LDFLAGS} -o goblog ./main.go
# run unittest
test: tidy
go test ./...
# build docker image
docker-build:
docker build --build-arg VERSION=${VERSION} -f ./Dockerfile -t goblog:${VERSION} .
# deploy by docker compose (.env file required! lookup .env.tmpl as example)
docker-deploy:
GOBLOG_IMAGE_TAG=${VERSION} docker compose up -d