## 1. Build Server # Use Go 1.14 FROM golang:1.14 AS build # Load repository into docker WORKDIR /project COPY . . # Load and run dependencies RUN go get # Build server and tools (CGO disabled to make them 100% static) ENV CGO_ENABLED 0 RUN go build -a -installsuffix cgo -ldflags="-s -w" -o logbot3 . ## 2. Distribute # Use alpine linux FROM alpine:3.12 as main-dist # Install certificates to enable HTTPS GET requests RUN apk add --no-cache ca-certificates # Copy build files into final container COPY --from=build /project/logbot3 /usr/local/bin/ # The server is the main entry point CMD ["/usr/local/bin/logbot3"]