From 43ddb362a9e20e22f9193b9e53acd7dfc1fb398f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 18 Oct 2020 15:50:49 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B3=20Add=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 22 ++++++++++++++++++++++ main.go | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7d82508 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.15 AS builder + +RUN mkdir /data && mkdir /data/shares + +ADD . /src +WORKDIR /src + +ENV CGO_ENABLED=0 + +RUN go build . + +# Actual image +FROM scratch + +ENV DATA_DIR=/data/shares +ENV DATABASE=/data/ShareDAV.db + +COPY --from=builder /src/ShareDAV /app/ShareDAV +COPY --from=builder /data /data + +ENTRYPOINT ["/app/ShareDAV"] +CMD ["serve"] \ No newline at end of file diff --git a/main.go b/main.go index 297a70e..b8860dc 100644 --- a/main.go +++ b/main.go @@ -35,8 +35,8 @@ import ( ) type config struct { - DataDirectory string `name:"data-dir" default:"data" help:"Directory to store all files in."` - Db string `name:"db" default:"ShareDAV.db" help:"Database file to use."` + DataDirectory string `name:"data-dir" default:"data" help:"Directory to store all files in." env:"DATA_DIR"` + Db string `name:"db" default:"ShareDAV.db" help:"Database file to use." env:"DATABASE"` } type app struct {