-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (40 loc) · 1.31 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
44
45
46
47
48
49
50
51
52
53
54
# Build environment
# -----------------
FROM golang:1.19.2-bullseye as builder
LABEL stage=builder
ARG DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y ca-certificates openssl git tzdata && \
update-ca-certificates && \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
COPY apis/ apis/
COPY internal/ internal/
COPY main.go main.go
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o /bin/app ./main.go && \
strip /bin/app
# Deployment environment
# ----------------------
FROM scratch
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /bin/app /bin/app
# Metadata params
ARG VERSION
ARG BUILD_DATE
ARG REPO_URL
ARG LAST_COMMIT
# Metadata
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url=$REPO_URL \
org.label-schema.vcs-ref=$LAST_COMMIT \
org.label-schema.version=$VERSION \
org.label-schema.docker.schema-version="1.0"
ENTRYPOINT ["/bin/app"]