diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..a33bc95 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,17 @@ +kind: pipeline +name: default + +steps: +- name: docker + image: plugins/docker + settings: + repo: sneak/hntransparency + dry_run: true + username: + from_secret: docker_username + password: + from_secret: docker_password + auto_tag: true + tags: + - ${DRONE_COMMIT_SHA} + - ${DRONE_BRANCH} diff --git a/.gitignore b/.gitignore index 9a3a8d8..5ad385c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +server diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d095398 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM golang:1.13 as builder + +WORKDIR /go/src/git.eeqj.de/sneak/hntransparencylog +COPY . . + +#RUN make lint && make build +RUN make build + +WORKDIR /go +RUN tar cvfz go-src.tgz src && du -sh * + +# this container doesn't do anything except hold the build artifact +# and make sure it compiles. + +FROM alpine + +COPY --from=builder /go/src/git.eeqj.de/sneak/hntransparencylog/server /bin/server + +# put the source in there too for safekeeping +COPY --from=builder /go/go-src.tgz /usr/local/src/go-src.tgz + +CMD /bin/server + +# FIXME add testing diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8c72eeb --- /dev/null +++ b/Makefile @@ -0,0 +1,80 @@ +VERSION := $(shell git rev-parse --short HEAD) +BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ') +BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ') +BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S') +BUILDUSER := $(shell whoami) +BUILDHOST := $(shell hostname -s) +BUILDARCH := $(shell uname -m) + +FN := server +IMAGENAME := sneak/hntransparencylog + +UNAME_S := $(shell uname -s) + +GOLDFLAGS += -X main.Version=$(VERSION) +GOLDFLAGS += -X main.Buildarch=$(BUILDARCH) + +# osx can't statically link apparently?! +ifeq ($(UNAME_S),Darwin) + GOFLAGS := -ldflags "$(GOLDFLAGS)" +endif + +ifneq ($(UNAME_S),Darwin) + GOFLAGS = -ldflags "-linkmode external -extldflags -static $(GOLDFLAGS)" +endif + +default: run + +debug: build + GOTRACEBACK=all DEBUG=1 ./$(FN) + +run: build + ./$(FN) + +clean: + -rm ./$(FN) + +build: ./$(FN) + +.lintsetup: + go get -v -u golang.org/x/lint/golint + go get -u github.com/GeertJohan/fgt + touch .lintsetup + +lint: fmt .lintsetup + fgt golint ./... + +go-get: + cd cmd/$(FN) && go get -v + +#./$(FN): */*.go cmd/*/*.go go-get +./$(FN): cmd/*/*.go go-get + cd cmd/$(FN) && go build -o ../../$(FN) $(GOFLAGS) . + +fmt: + gofmt -s -w . + +test: lint build-docker-image + +is_uncommitted: + git diff --exit-code >/dev/null 2>&1 + +build-docker-image: clean + docker build -t $(IMAGENAME) . + +build-docker-image-dist: is_uncommitted clean + docker build -t $(IMAGENAME):$(VERSION) -t $(IMAGENAME):latest -t $(IMAGENAME):$(BUILDTIMETAG) . + +dist: lint build-docker-image + -mkdir -p ./output + docker run --rm --entrypoint cat $(IMAGENAME) /bin/$(FN) > output/$(FN) + docker save $(IMAGENAME) | bzip2 > output/$(BUILDTIMEFILENAME).$(FN).tbz2 + +hub: upload-docker-image + +upload-docker-image: build-docker-image + docker push $(IMAGENAME):$(VERSION) + docker push $(IMAGENAME):$(BUILDTIMETAG) + docker push $(IMAGENAME):latest + +.PHONY: build fmt test is_uncommitted build-docker-image dist hub upload-docker-image clean run rundebug default build-docker-image-dist diff --git a/_layouts/base.html b/_layouts/base.html new file mode 100644 index 0000000..2b6825e --- /dev/null +++ b/_layouts/base.html @@ -0,0 +1,74 @@ + + + +
+ + + + + +Complete with pre-defined file paths and responsive navigation!
+