2019-10-24 10:38:16 +00:00
|
|
|
VERSION := $(shell git rev-parse --short HEAD)
|
|
|
|
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
2019-10-24 15:23:29 +00:00
|
|
|
BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ')
|
2019-10-24 15:33:57 +00:00
|
|
|
BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S')
|
2019-10-24 10:38:16 +00:00
|
|
|
BUILDUSER := $(shell whoami)
|
|
|
|
BUILDHOST := $(shell hostname -s)
|
|
|
|
BUILDARCH := $(shell uname -m)
|
|
|
|
|
2019-10-24 15:23:29 +00:00
|
|
|
FN := fediverse-archive
|
|
|
|
IMAGENAME := sneak/$(FN)
|
|
|
|
|
2019-10-24 10:38:16 +00:00
|
|
|
GOLDFLAGS += -X main.Version=$(VERSION)
|
|
|
|
GOLDFLAGS += -X main.Buildtime=$(BUILDTIME)
|
|
|
|
GOLDFLAGS += -X main.Builduser=$(BUILDUSER)@$(BUILDHOST)
|
|
|
|
GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
|
2019-10-24 16:07:41 +00:00
|
|
|
GOFLAGS = -ldflags "-linkmode external -extldflags -static $(GOLDFLAGS)"
|
2019-10-24 10:38:16 +00:00
|
|
|
|
|
|
|
default: rundebug
|
|
|
|
|
|
|
|
rundebug: build
|
2019-10-24 15:23:29 +00:00
|
|
|
./$(FN) -debug
|
2019-10-24 10:38:16 +00:00
|
|
|
|
|
|
|
run: build
|
2019-10-24 15:23:29 +00:00
|
|
|
./$(FN)
|
2019-10-24 10:38:16 +00:00
|
|
|
|
2019-10-24 15:23:29 +00:00
|
|
|
build: ./$(FN)
|
2019-10-24 10:38:16 +00:00
|
|
|
|
2019-10-24 15:23:29 +00:00
|
|
|
./$(FN): *.go
|
2019-10-24 10:38:16 +00:00
|
|
|
go build -o $@ $(GOFLAGS) .
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
go fmt *.go
|
|
|
|
|
2019-10-24 15:23:29 +00:00
|
|
|
test: build-docker-image
|
|
|
|
|
|
|
|
build-docker-image:
|
2019-10-24 15:33:57 +00:00
|
|
|
docker build -t $(IMAGENAME):$(VERSION) -t $(IMAGENAME):latest -t $(IMAGENAME):$(BUILDTIMETAG) .
|
2019-10-24 15:23:29 +00:00
|
|
|
|
|
|
|
dist: build-docker-image
|
|
|
|
-mkdir -p ./output
|
|
|
|
docker run --rm --entrypoint cat $(IMAGENAME) /bin/$(FN) > output/$(FN)
|
|
|
|
docker save $(IMAGENAME) | bzip2 > output/$(BUILDTIMEFILENAME).$(FN).tbz2
|
2019-10-24 15:33:57 +00:00
|
|
|
|
|
|
|
hub: upload-docker-image
|
|
|
|
|
|
|
|
upload-docker-image: build-docker-image
|
|
|
|
docker push $(IMAGENAME):$(VERSION)
|
|
|
|
docker push $(IMAGENAME):$(BUILDTIMETAG)
|
|
|
|
docker push $(IMAGENAME):latest
|