From 59d5489314d5be4916dea0161741b0ac82da3fca Mon Sep 17 00:00:00 2001 From: machinekey Date: Fri, 13 Jan 2023 10:50:58 -0800 Subject: [PATCH 1/2] Add all docker stuff --- Dockerfile | 26 ++++++++++++++++++++++++++ Makefile | 16 ++++++++++++---- docker-compose.yml | 8 ++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml 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..ced9a1f 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,linux/arm/v7 -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 From 59eda89cccf1925aa8038ed0051f8242986ef753 Mon Sep 17 00:00:00 2001 From: Cobular <22972550+JakeCover@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:09:56 +0000 Subject: [PATCH 2/2] Removed armv7, that seems to hang --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ced9a1f..9aca18f 100644 --- a/Makefile +++ b/Makefile @@ -74,4 +74,4 @@ docker: $(GOFILES) docker build -t $(DOCKER_WHOLETAG) . docker_buildkit_all: $(GOFILES) - docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t $(DOCKER_WHOLETAG) . + docker buildx build --platform linux/amd64,linux/arm64 -t $(DOCKER_WHOLETAG) .