Update Dockerfile

This commit is contained in:
Alexey 2026-03-24 22:36:20 +03:00 committed by GitHub
parent 11df61c6ac
commit 101efe45b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 29 additions and 33 deletions

View File

@ -1,8 +1,7 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
ARG TARGETARCH ARG TELEMT_REPOSITORY=telemt/telemt
ARG BINARY_AMD64 ARG TELEMT_VERSION=latest
ARG BINARY_ARM64
# ========================== # ==========================
# Minimal Image # Minimal Image
@ -10,54 +9,51 @@ ARG BINARY_ARM64
FROM debian:12-slim AS minimal FROM debian:12-slim AS minimal
ARG TARGETARCH ARG TARGETARCH
ARG BINARY_AMD64 ARG TELEMT_REPOSITORY
ARG BINARY_ARM64 ARG TELEMT_VERSION
RUN set -eux; \ RUN set -eux; \
apt-get update; \ apt-get update; \
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \
binutils \ binutils \
ca-certificates \
curl \ curl \
xz-utils \ tar; \
ca-certificates; \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# --- Select correct binary ---
RUN set -eux; \ RUN set -eux; \
case "${TARGETARCH}" in \ case "${TARGETARCH}" in \
amd64) BIN="${BINARY_AMD64}" ;; \ amd64) ASSET="telemt-x86_64-linux-musl.tar.gz" ;; \
arm64) BIN="${BINARY_ARM64}" ;; \ arm64) ASSET="telemt-aarch64-linux-musl.tar.gz" ;; \
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \ *) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
esac; \ esac; \
echo "Using binary: $BIN"; \ VERSION="${TELEMT_VERSION#refs/tags/}"; \
test -f "$BIN"; \ if [ -z "${VERSION}" ] || [ "${VERSION}" = "latest" ]; then \
cp "$BIN" /telemt BASE_URL="https://github.com/${TELEMT_REPOSITORY}/releases/latest/download"; \
else \
# --- Install UPX (arch-aware) --- BASE_URL="https://github.com/${TELEMT_REPOSITORY}/releases/download/${VERSION}"; \
RUN set -eux; \ fi; \
case "${TARGETARCH}" in \
amd64) UPX_ARCH="amd64" ;; \
arm64) UPX_ARCH="arm64" ;; \
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
esac; \
\
curl -fL \ 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/${ASSET}" \
"https://github.com/telemt/telemt/releases/download/toolchains/upx-${UPX_ARCH}_linux.tar.xz"; \ "${BASE_URL}/${ASSET}"; \
\ curl -fL \
tar -xf /tmp/upx.tar.xz -C /tmp; \ --retry 5 \
install -m 0755 /tmp/upx*/upx /usr/local/bin/upx; \ --retry-delay 3 \
rm -rf /tmp/upx* --connect-timeout 10 \
--max-time 120 \
# --- Optimize binary --- -o "/tmp/${ASSET}.sha256" \
RUN set -eux; \ "${BASE_URL}/${ASSET}.sha256"; \
test -f /telemt; \ cd /tmp; \
sha256sum -c "${ASSET}.sha256"; \
tar -xzf "${ASSET}" -C /tmp; \
test -f /tmp/telemt; \
install -m 0755 /tmp/telemt /telemt; \
strip --strip-unneeded /telemt || true; \ strip --strip-unneeded /telemt || true; \
upx --best --lzma /telemt || true rm -f "/tmp/${ASSET}" "/tmp/${ASSET}.sha256" /tmp/telemt
# ========================== # ==========================
# Debug Image # Debug Image