diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7a4c075 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# syntax=docker/dockerfile:1 + +## Build +FROM golang:1.16-buster AS build + +WORKDIR /app + +COPY go.mod ./ +RUN go mod download + +COPY *.go ./ + +RUN go build -o /http-file-server + +## Deploy +FROM gcr.io/distroless/base-debian10 + +WORKDIR / + +COPY --from=build /http-file-server /http-file-server + +EXPOSE 8080 + +USER nonroot:nonroot + +ENTRYPOINT ["/http-file-server", "/mount"] \ No newline at end of file diff --git a/Makefile b/Makefile index 67dd283..9aca18f 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ VERSION = 1.6.1 -APP := http-file-server -PACKAGES := $(shell go list -f {{.Dir}} ./...) -GOFILES := $(addsuffix /*.go,$(PACKAGES)) -GOFILES := $(wildcard $(GOFILES)) +APP := http-file-server +PACKAGES := $(shell go list -f {{.Dir}} ./...) +GOFILES := $(addsuffix /*.go,$(PACKAGES)) +GOFILES := $(wildcard $(GOFILES)) +DOCKER_REPONAME := gcr.io/sgreben/http-file-server +DOCKER_WHOLETAG := $(DOCKER_REPONAME):$(VERSION) .PHONY: clean release README.md @@ -67,3 +69,9 @@ release/$(APP)_$(VERSION)_linux_arm64.tar.gz: binaries/linux_arm64/$(APP) binaries/linux_arm64/$(APP): $(GOFILES) GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/linux_arm64/$(APP) . + +docker: $(GOFILES) + docker build -t $(DOCKER_WHOLETAG) . + +docker_buildkit_all: $(GOFILES) + docker buildx build --platform linux/amd64,linux/arm64 -t $(DOCKER_WHOLETAG) . diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9a0b931 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3.9" +services: + web: + build: . + ports: + - "8000:8080" + volumes: + - ./share:/mount \ No newline at end of file