Skip to content
This repository was archived by the owner on Apr 5, 2026. It is now read-only.
This repository was archived by the owner on Apr 5, 2026. It is now read-only.

Docker: reduce image size (Ubuntu 150MB+ → Alpine/slim ~30MB) #49

@dvershinin

Description

@dvershinin

Problem

Our Docker image uses Ubuntu 22.04 as runtime base, resulting in ~150MB+ images. Competing implementations are much smaller:

Proxy Base Image Size
mtg scratch (static Go binary) ~20 MB
telemt distroless + UPX ~30 MB
Ours Ubuntu 22.04 + runtime deps ~150+ MB

Current Runtime Dependencies

RUN apt-get install -y libssl3 zlib1g curl ca-certificates vim-common cron iproute2
  • libssl3, zlib1g — required for the binary
  • curl — for downloading proxy-multi.conf and external IP detection
  • vim-common — only for xxd (secret generation)
  • cron — for 6-hourly config refresh
  • iproute2 — for ip route (local IP detection)

Proposed Approach

Option A: Alpine Linux (~30MB)

FROM alpine:3.21
RUN apk add --no-cache openssl zlib curl ca-certificates
  • Replace cron with Alpine's crond (from busybox, already included)
  • Replace xxd with od or openssl rand -hex 16
  • Replace iproute2 with Alpine's ip from busybox

Option B: Static linking + scratch/distroless

  • Statically link OpenSSL and zlib at build time
  • Use multi-stage build with scratch base
  • Ship curl as a separate static binary or use a lightweight HTTP client
  • Most complex but smallest result

Option C: Debian slim (~50MB)

FROM debian:bookworm-slim
  • Simplest migration, moderate size reduction
  • All packages available without rebuilding

Recommendation

Option A (Alpine) offers the best balance of size reduction and compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions