werc/docker.mk

18 lines
560 B
Makefile

P=gowerc
SRC=git.froth.zone
USER?=fishe
GO_VERSION=1.18
docker: $(USER)/$(P)
$(USER)/$(P): bin/$(P)
docker build -t "$(USER)/$(P):latest" .
bin/$(P): *.go
docker run --rm -v ${PWD}:/go/src/$(SRC)/$(USER)/$(P) golang:${GO_VERSION} /bin/bash -c "go list -f '{{range .Imports}}{{printf \"%s\n\" .}}{{end}}' $(SRC)/$(USER)/$(P) | xargs go get -d; CGO_ENABLED=0 go build -v -installsuffix cgo -o /go/src/$(SRC)/$(USER)/$(P)/bin/$(P) $(SRC)/$(USER)/$(P)"
clean:
docker run --rm -v ${PWD}:/opt busybox rm -f /opt/bin/$(P)
docker rmi -f "$(USER)/$(P):latest"