From e6b85840018bdc3eef07dbdd36e06452ec52f075 Mon Sep 17 00:00:00 2001 From: Jorge Luis Betancourt Gonzalez Date: Fri, 26 Jun 2020 10:58:48 +0200 Subject: [PATCH] Docker build --- Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4206c97 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:latest as builder +ARG MOD +ENV MOD ${MOD:-readonly} +RUN mkdir /build +ADD . /build/ +WORKDIR /build +RUN echo "go mod flag: $MOD" +RUN CGO_ENABLED=0 GOOS=linux go build -mod=$MOD -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main . + +FROM alpine +WORKDIR /app +COPY --from=builder /build/main /app +EXPOSE 8080 +CMD ["./main"]