Purva09/algorithm-battlefield
0
1# Use the official lightweight Python 3.11 image2FROM python:3.11-slim3 4# Set environment variables5ENV PYTHONDONTWRITEBYTECODE=1 \6 PYTHONUNBUFFERED=1 \7 HOME=/home/user8 9# Create a non-root user 'user' with UID 100010RUN useradd -m -u 1000 user11 12# Set working directory inside user home13WORKDIR $HOME/app14 15# Copy requirements first to leverage Docker cache16COPY requirements.txt .17 18# Upgrade pip and install dependencies19RUN pip install --no-cache-dir --upgrade pip && \20 pip install --no-cache-dir -r requirements.txt21 22# Copy the rest of the application files, ensuring the non-root user owns them23COPY --chown=user:user . .24 25# Pre-create the flask_session directory and ensure write permissions26RUN mkdir -p flask_session && chmod -R 777 flask_session27 28# Switch to the non-root user29USER user30 31# Set Hugging Face port environment variable32ENV PORT=786033EXPOSE 786034 35# Run the app using Gunicorn36CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "app:app"]37 