go-nurl/Makefile
2024-09-20 12:13:29 +01:00

40 lines
928 B
Makefile

PROJECT = go-pb-nurl
VERSION=`git describe --tags`
BUILD=`date +%yw%Vb`
ECR_REPO = git.caliban.io/martin
APP_IMAGE = $(ECR_REPO)/$(PROJECT):$(VERSION)
NO_CACHE = true
LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION} -X main.Build=${BUILD}"
.PHONY: build
build:
#CC=/usr/local/musl/bin/musl-gcc go build --ldflags '-linkmode external -extldflags "-static"' server.go
GCO_ENABLED=0 GOOS=linux go build ${LDFLAGS} -o ${PROJECT} main.go
# go build ${LDFLAGS} -o ${PROJECT} server.go
# docker build ./docker/. -t $(APP_IMAGE) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE) --compress=true
docker build --platform linux/amd64 --no-cache -force-rm --tag ${APP_IMAGE} --file ./docker/Dockerfile .
#push docker image to registry
.PHONY: push
push: build
docker push $(APP_IMAGE)
#push docker image to registry
.PHONY: run
run: build
docker run $(APP_IMAGE)
ver:
@echo '$(VERSION)'
#echo $ERSION
.PHONY: ver