Slimming down

This commit is contained in:
2025-10-30 14:55:37 +01:00
parent 3678efed07
commit f881c13df3
10 changed files with 852 additions and 24 deletions

View File

@@ -1,13 +1,37 @@
# Multi-stage build for efficient container size
# Stage 1: Builder with all compilation dependencies
FROM python:3.13-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
make \
build-essential \
cargo \
rustc \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
# Stage 2: Final lightweight image
FROM python:3.13-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
TZ=Europe/Berlin
TZ=Europe/Berlin \
PATH=/root/.local/bin:$PATH
# Install minimal dependencies
# Install only runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
tzdata \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
@@ -15,11 +39,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# Set working directory
WORKDIR /app
# Copy dependency files
COPY requirements.txt ./
# Install Python dependencies using pip (simpler for container)
RUN pip install --no-cache-dir -r requirements.txt
# Copy Python packages from builder
COPY --from=builder /root/.local /root/.local
# Copy application files
COPY main.py .