about summary refs log tree commit diff
path: root/Dockerfile
diff options
context:
space:
mode:
authorhanemile <mail@emile.space>2020-07-19 01:56:09 +0200
committerhanemile <mail@emile.space>2020-07-19 01:56:09 +0200
commitfc63adf55849f748a37cef4c425a19a1c0f0e76e (patch)
tree034c6ab3abb08fe15c702298f294226f1b0071c2 /Dockerfile
initial commit
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile33
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"]