37 lines
996 B
Docker
37 lines
996 B
Docker
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install curl for healthcheck and other dependencies
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends curl && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first for better caching
|
|
COPY src/requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Install development tools
|
|
RUN pip install --no-cache-dir pytest pytest-cov black isort
|
|
|
|
# Copy the rest of the application
|
|
COPY src/ .
|
|
|
|
# Create directory for static files
|
|
RUN mkdir -p /app/static && chmod 777 /app/static
|
|
|
|
# Create non-root user for security
|
|
RUN adduser --disabled-password --gecos '' appuser
|
|
RUN chown -R appuser:appuser /app
|
|
USER appuser
|
|
|
|
# Expose the port the app runs on
|
|
EXPOSE 3000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:3000/health || exit 1
|
|
|
|
# Start with uvicorn for hot reloading
|
|
CMD uvicorn app:app --host 0.0.0.0 --port 3000 --reload |