Update Dockerfile

This commit is contained in:
Alexey 2026-03-24 11:46:49 +03:00 committed by GitHub
parent 1450af60a0
commit 22097f8c7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 38 additions and 22 deletions

View File

@ -1,48 +1,64 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
ARG BINARY ARG BINARY
ARG TARGETARCH
# ========================== # ==========================
# Stage: minimal # Stage: minimal
# ========================== # ==========================
FROM debian:12-slim AS minimal FROM debian:12-slim AS minimal
RUN apt-get update && apt-get install -y --no-install-recommends \ ARG TARGETARCH
binutils \ ARG BINARY
curl \
xz-utils \ RUN set -eux; \
ca-certificates \ apt-get update; \
&& rm -rf /var/lib/apt/lists/* \ apt-get install -y --no-install-recommends \
binutils \
curl \
xz-utils \
ca-certificates; \
rm -rf /var/lib/apt/lists/*; \
\ \
&& curl -fL \ case "${TARGETARCH}" in \
amd64) UPX_ARCH="amd64" ;; \
arm64) UPX_ARCH="arm64" ;; \
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
esac; \
\
curl -fL \
--retry 5 \ --retry 5 \
--retry-delay 3 \ --retry-delay 3 \
--connect-timeout 10 \ --connect-timeout 10 \
--max-time 120 \ --max-time 120 \
-o /tmp/upx.tar.xz \ -o /tmp/upx.tar.xz \
https://github.com/telemt/telemt/releases/download/toolchains/upx-amd64_linux.tar.xz \ "https://github.com/telemt/telemt/releases/download/toolchains/upx-${UPX_ARCH}_linux.tar.xz"; \
&& tar -xf /tmp/upx.tar.xz -C /tmp \ \
&& mv /tmp/upx*/upx /usr/local/bin/upx \ tar -xf /tmp/upx.tar.xz -C /tmp; \
&& chmod +x /usr/local/bin/upx \ install -m 0755 /tmp/upx*/upx /usr/local/bin/upx; \
&& rm -rf /tmp/upx* rm -rf /tmp/upx*
COPY ${BINARY} /telemt COPY ${BINARY} /telemt
RUN strip /telemt || true RUN set -eux; \
RUN upx --best --lzma /telemt || true test -f /telemt; \
strip --strip-unneeded /telemt || true; \
upx --best --lzma /telemt || true
# ========================== # ==========================
# Debug image # Debug image
# ========================== # ==========================
FROM debian:12-slim AS debug FROM debian:12-slim AS debug
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN set -eux; \
ca-certificates \ apt-get update; \
tzdata \ apt-get install -y --no-install-recommends \
curl \ ca-certificates \
iproute2 \ tzdata \
busybox \ curl \
&& rm -rf /var/lib/apt/lists/* iproute2 \
busybox; \
rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
@ -55,7 +71,7 @@ ENTRYPOINT ["/app/telemt"]
CMD ["config.toml"] CMD ["config.toml"]
# ========================== # ==========================
# Production (REAL distroless) # Production (distroless, for static MUSL binary)
# ========================== # ==========================
FROM gcr.io/distroless/static-debian12 AS prod FROM gcr.io/distroless/static-debian12 AS prod