github.com/dhax/go-base@v0.0.0-20231004214136-8be7e5c1972b/Dockerfile (about) 1 FROM golang AS builder 2 3 WORKDIR /src 4 # Download dependencies 5 COPY go.mod go.sum / 6 RUN go mod download 7 8 # Add source code 9 COPY . . 10 RUN CGO_ENABLED=0 go build -o main . 11 12 # Multi-Stage production build 13 FROM alpine AS production 14 RUN apk --no-cache add ca-certificates 15 16 WORKDIR /app 17 # Retrieve the binary from the previous stage 18 COPY --from=builder /src/main . 19 # Copy static template files 20 COPY templates templates 21 # Copy frontend 22 COPY public public 23 # Expose port 24 EXPOSE 3000 25 # Set the binary as the entrypoint of the container 26 CMD ["./main", "serve"]