# Use official Python runtime as base image FROM python:3.12-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ curl \ && rm -rf /var/lib/apt/lists/* # Install uv for fast Python package management RUN pip install uv # Copy dependency files COPY pyproject.toml uv.lock ./ # Install dependencies only (not the local package) RUN uv export --format requirements-txt --no-hashes > requirements.txt && \ uv venv && \ uv pip install -r requirements.txt # Copy application code COPY src/ ./src/ COPY web_server.py ./ COPY korean_mud_game.html ./ COPY assets/ ./assets/ # Create non-root user for security RUN useradd --create-home --shell /bin/bash appuser && \ chown -R appuser:appuser /app USER appuser # Expose port for HuggingFace Spaces EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/api/game/help || exit 1 # Set environment variables ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 ENV DOCKER_ENV=1 # Run the application CMD ["uv", "run", "python", "web_server.py"]