diff --git a/Dockerfile b/Dockerfile index 66f5e07..6e860bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM golang:1.13 as builder -WORKDIR /go/src/github.com/sneak/pooteeweet +WORKDIR /go/src/github.com/sneak/merp COPY . . RUN go get -v && make build @@ -8,8 +8,11 @@ RUN go get -v && make build FROM alpine -COPY --from=builder /go/src/github.com/sneak/pooteeweet/pooteeweet /bin/pooteeweet +COPY --from=builder /go/src/github.com/sneak/merp/merp /bin/merp -CMD /bin/pooteeweet +# put the source in there too for safekeeping +COPY --from=builder /go/src /usr/local/src/go + +CMD /bin/merp # FIXME add testing diff --git a/Makefile b/Makefile index 13a8c19..956ae2c 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,20 @@ +APPNAME := merp + VERSION := $(shell git rev-parse --short HEAD) BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ') BUILDUSER := $(shell whoami) BUILDHOST := $(shell hostname -s) BUILDARCH := $(shell uname -m) -APPNAME := merp +BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S') +BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ') +IMAGENAME := sneak/$(APPNAME) GOLDFLAGS += -X main.Version=$(VERSION) GOLDFLAGS += -X main.Buildtime=$(BUILDTIME) GOLDFLAGS += -X main.Builduser=$(BUILDUSER)@$(BUILDHOST) GOLDFLAGS += -X main.Buildarch=$(BUILDARCH) GOLDFLAGS += -X main.Appname=$(APPNAME) -GOFLAGS = -ldflags "$(GOLDFLAGS)" +GOFLAGS = -ldflags "-linkmode external -extldflags -static $(GOLDFLAGS)" default: run @@ -28,14 +32,23 @@ clean: fmt: go fmt *.go -test: build-image +test: build-docker-image -build-and-push-image: push-image +dist: build-docker-image + -mkdir -p ./output + docker run --rm --entrypoint cat $(IMAGENAME) /bin/$(APPNAME) > output/$(APPNAME) + docker save $(IMAGENAME) | bzip2 > output/$(BUILDTIMEFILENAME).$(APPNAME).tbz2 -push-image: build-image - docker push sneak/$(APPNAME) +hub: upload-docker-image -build-image: +build-docker-image: docker build \ - -t sneak/$(APPNAME):$(VERSION) \ + -t $(IMAGENAME):$(VERSION) \ + -t $(IMAGENAME):latest \ + -t $(IMAGENAME):$(BUILDTIMETAG) \ . + +upload-docker-image: build-docker-image + docker push $(IMAGENAME):$(VERSION) + docker push $(IMAGENAME):$(BUILDTIMETAG) + docker push $(IMAGENAME):latest diff --git a/merp.go b/merp.go index 080991d..cec11e9 100644 --- a/merp.go +++ b/merp.go @@ -7,11 +7,13 @@ import "time" import "github.com/rs/zerolog/log" import "github.com/gin-gonic/gin" +/* func GetLatestMerps() gin.HandlerFunc { } func GetLatestMerp() gin.HandlerFunc { } +*/ func HandleNewMerp() gin.HandlerFunc {