50 lines
1.3 KiB
Text
50 lines
1.3 KiB
Text
# Development Docker image with hot reload
|
|
FROM python:3.13-slim
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
libc6-dev \
|
|
zlib1g \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user for development
|
|
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
|
|
|
RUN mkdir -p /home/appuser
|
|
RUN chown -R appuser:appuser /home/appuser
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
COPY LICENSE README.md ./
|
|
|
|
# Install hatch for dependency management
|
|
RUN pip install --no-cache-dir hatch
|
|
|
|
# Copy pyproject.toml first for dependency caching
|
|
COPY pyproject.toml ./
|
|
|
|
# Generate and install dependencies
|
|
RUN hatch dep show requirements > requirements.txt
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy templates directory (needed at runtime)
|
|
COPY templates/ ./templates/
|
|
|
|
# Change ownership of the app directory to appuser
|
|
RUN chown -R appuser:appuser /app
|
|
|
|
# Switch to non-root user
|
|
USER appuser
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
# Expose port
|
|
EXPOSE 80
|
|
|
|
# The source code will be mounted as a volume
|
|
# Install in editable mode and run with auto-reload
|
|
CMD ["sh", "-c", "pip install -e . && uvicorn random_access.main:app --host 0.0.0.0 --port 80 --reload --reload-dir /app/src"]
|