diff options
author | hanemile <mail@emile.space> | 2020-07-19 13:16:17 +0200 |
---|---|---|
committer | hanemile <mail@emile.space> | 2020-07-19 13:16:17 +0200 |
commit | 04f3229998c854f6483f447b6ea598f81c628b91 (patch) | |
tree | 8b138aac4cdee8bac237e97ec9f82e92c6e6aa68 | |
parent | 2cdd6a5f64a35b06ed6ab7b5f77841223261f2f3 (diff) |
basic dockerfile
-rw-r--r-- | Dockerfile | 33 |
1 files changed, 33 insertions, 0 deletions
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"] |