-
Notifications
You must be signed in to change notification settings - Fork 604
/
Dockerfile.debian
48 lines (35 loc) · 1.25 KB
/
Dockerfile.debian
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
ARG DOCKER_GEN_VERSION=main
# Build docker-gen from scratch
FROM --platform=$BUILDPLATFORM golang:1.23.3 AS go-builder
ENV CGO_ENABLED=0
ARG DOCKER_GEN_VERSION TARGETOS TARGETARCH TARGETVARIANT
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH VARIANT=$TARGETVARIANT
WORKDIR /build
# Install the dependencies
COPY . .
RUN go mod download
# Build the docker-gen executable
RUN set -eux; \
case "$GOARCH" in \
arm) export GOARM="${VARIANT#v}" ;; \
amd64) export GOAMD64="$VARIANT" ;; \
*) [ -z "$VARIANT" ] ;; \
esac; \
go env | grep -E 'OS=|ARCH=|ARM=|AMD64='; \
go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" -o docker-gen ./cmd/docker-gen
FROM debian:12.8-slim
ARG DOCKER_GEN_VERSION
ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
DOCKER_HOST=unix:///tmp/docker.sock
# Install packages required by the image
RUN apt-get update \
&& apt-get install -y -q --no-install-recommends openssl \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/*
# Copy the entrypoint script
COPY /app/docker-entrypoint.sh /app/docker-entrypoint.sh
# Install docker-gen from build stage
COPY --from=go-builder /build/docker-gen /usr/local/bin/docker-gen
# Copy the license
COPY LICENSE /usr/local/share/doc/docker-gen/
ENTRYPOINT ["/app/docker-entrypoint.sh"]