-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (32 loc) · 1.34 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
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.23
ARG DEBIAN_VERSION=bookworm
ARG DOCKER_REGISTRY=docker.io
ARG LD_FLAGS="-w -extldflags '-static'"
FROM ${DOCKER_REGISTRY}/library/golang:${GO_VERSION}-${DEBIAN_VERSION} AS build_base
WORKDIR /workspace
ENV CGO_ENABLED=0
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -y git
FROM build_base AS build_deps
COPY --link go.mod ./
COPY --link go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
FROM build_deps AS build
ARG LD_FLAGS
COPY --link . ./
RUN --mount=type=cache,target=/root/.cache/go-build \
go build -o webhook -ldflags "${LD_FLAGS}" .
FROM ${DOCKER_REGISTRY}/library/debian:${DEBIAN_VERSION}-slim AS runtime
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -y ca-certificates && \
update-ca-certificates
COPY --from=build /workspace/webhook /usr/local/bin/webhook
ENTRYPOINT ["webhook"]