Slimming down
This commit is contained in:
		
							
								
								
									
										35
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -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 .
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user