From d70251a4fb77c6fc0cd83d1d643ff56adb7e8d04 Mon Sep 17 00:00:00 2001 From: Lukas SP Date: Sun, 23 Aug 2020 21:05:20 +0200 Subject: [PATCH] Dockerize the application --- Dockerfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..da86034 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Build the application +FROM golang:1.15-alpine AS build +RUN apk update && apk upgrade && \ + apk add --no-cache bash git openssh +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN go build \ + -o pasty \ + -ldflags "\ + -X github.com/Lukaesebrot/pasty/internal/static.Version=$(git rev-parse --abbrev-ref HEAD)-$(git describe --tags --abbrev=0)-$(git log --pretty=format:'%h' -n 1)" \ + ./cmd/pasty/main.go + +# Run the application in an empty alpine environment +FROM alpine:latest +WORKDIR /root +COPY --from=build /app/pasty . +COPY web ./web/ +CMD ["./pasty"] \ No newline at end of file