From 8fc8df6fce2f49f29d9098effaff5501e450e736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Sierra?= Date: Sun, 26 Jan 2020 00:38:57 +0100 Subject: [PATCH] Add dockerfile --- Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fc7a146 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM golang:1.13.6-alpine3.11 as builder + +WORKDIR /go/src/app + +COPY . . + +# There is a roblem with net lib bindings and CGO_ENABLED is needed +# https://stackoverflow.com/questions/36279253/go-compiled-binary-wont-run-in-an-alpine-docker-container-on-ubuntu-host +RUN CGO_ENABLED=0 go build -o server -v . + +# ============================== +# Stage 2: Run the isolated build in a lightweight image +# ============================== + +FROM alpine:3.11 + +WORKDIR /app + +EXPOSE 8100 + +ENTRYPOINT ["/app/server"] +CMD ["-p", "8100", "-d", "/files"] + +COPY statics/ ./statics +COPY templates/ ./templates +COPY --from=builder /go/src/app/server ./ + +VOLUME /files