30 lines
842 B
Docker
30 lines
842 B
Docker
# Use specific version for reproducible builds
|
|
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11
|
|
|
|
# Set Python optimizations
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PIP_NO_CACHE_DIR=1
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
# Install system dependencies (PostgreSQL client libraries)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libpq-dev \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy and install Python dependencies
|
|
COPY requirements.txt ./
|
|
RUN pip install --no-cache-dir --upgrade pip && \
|
|
pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY ./app /app/app
|
|
|
|
# Create directories for volumes
|
|
RUN mkdir -p /usr/src/app/storage
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
|
CMD curl -f http://localhost:80/api/v3/current || exit 1 |