This commit is contained in:
pika 2025-03-31 17:27:03 +02:00
parent 3036042416
commit da0a156ada
5 changed files with 159 additions and 13 deletions

View file

@ -9,17 +9,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install gunicorn psycopg2-binary redis
# Copy application code
# Upgrade pip and install dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# Copy the rest of the application
COPY . .
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Create a non-root user to run the app
RUN useradd -m appuser && \
chown -R appuser:appuser /app
# Run the application
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "wsgi:app"]
USER appuser
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Run gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "4", "wsgi:app"]