homedocs/Dockerfile
2025-04-03 13:51:52 +02:00

38 lines
863 B
Docker

FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Upgrade pip and install dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# Copy the rest of the application
COPY . .
# Create the instance directory for SQLite
# RUN mkdir -p instance && \
# chmod 777 instance
# Create a non-root user to run the app
# RUN useradd -m appuser && \
# chown -R appuser:appuser /app
# USER appuser
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FLASK_APP=wsgi.py
# Run gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--timeout", "120", "--workers", "4", "run:app"]