57 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
# 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 \
 | 
						|
    PATH=/root/.local/bin:$PATH
 | 
						|
 | 
						|
# 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
 | 
						|
 | 
						|
# Set working directory
 | 
						|
WORKDIR /app
 | 
						|
 | 
						|
# Copy Python packages from builder
 | 
						|
COPY --from=builder /root/.local /root/.local
 | 
						|
 | 
						|
# Copy application files
 | 
						|
COPY main.py .
 | 
						|
COPY Vektor-Logo.svg ./
 | 
						|
 | 
						|
# Create static directory and copy logo
 | 
						|
RUN mkdir -p static && \
 | 
						|
    cp Vektor-Logo.svg static/logo.svg
 | 
						|
 | 
						|
# Expose port
 | 
						|
EXPOSE 8000
 | 
						|
 | 
						|
# Run the application
 | 
						|
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] |