-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
43 lines (34 loc) · 1.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
ARG GOLANG_VERSION=1.18
ARG ALPINE_VERSION=3.15
FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS builder
ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV PROJECT=pg-graylogger
WORKDIR ${PROJECT}
COPY go.mod go.sum ./
RUN go mod download
# Copy src code from the host and compile it
COPY . .
RUN go build -a -o /${PROJECT} .
### Base image with shell
FROM alpine:${ALPINE_VERSION} as base-release
RUN apk --update --no-cache add ca-certificates && update-ca-certificates
ENTRYPOINT ["/bin/pg-graylogger"]
### Build with goreleaser
FROM base-release as goreleaser
COPY pg-graylogger /bin/
### Build in docker
FROM base-release as release
COPY --from=builder /pg-graylogger /bin/
### Scratch with build in docker
FROM scratch as scratch-release
COPY --from=base-release /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /pg-graylogger /bin/
ENTRYPOINT ["/bin/pg-graylogger"]
USER 65534
### Scratch with goreleaser
FROM scratch as scratch-goreleaser
COPY --from=base-release /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY pg-graylogger /bin/
ENTRYPOINT ["/bin/pg-graylogger"]
USER 65534