From 04f3229998c854f6483f447b6ea598f81c628b91 Mon Sep 17 00:00:00 2001 From: hanemile Date: Sun, 19 Jul 2020 13:16:17 +0200 Subject: basic dockerfile --- Dockerfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..60a0f37 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +######################################## +# Stage 1: build the project +######################################## + +FROM golang:1.14 as build-env + +# define the workdir an add the files needed to build the project there +WORKDIR /go/src/app +ADD . /go/src/app + +# define the GOBIN env var and add it to the path +ENV GOBIN="$GOPATH/bin" +ENV PATH="$GOBIN:$PATH" + +# Fetch all dependencies +RUN go get -d -v ./... + +# Build the actual project storing the resulting binary in /go/bin/freitagsfoo +RUN go build -o /go/bin/freitagsfoo ./src + +######################################## +# Stage 2: exec in using tiny base image +######################################## + +FROM gcr.io/distroless/base + +# copy the needed files from the build env +COPY --from=build-env /go/bin/freitagsfoo / +COPY --from=build-env /go/src/app/hosted/ /hosted/ +COPY --from=build-env /go/src/app/uploads/ /uploads/ + +# exec the build binary +ENTRYPOINT ["/freitagsfoo"] -- cgit 1.4.1