Spaces:
Sleeping
Sleeping
File size: 1,439 Bytes
eed6dfe ff17fc2 d7dae1c eed6dfe d7dae1c 4ff5731 eed6dfe ff17fc2 23ca858 eed6dfe ff17fc2 eed6dfe ff17fc2 d7dae1c ff17fc2 eed6dfe ff17fc2 eed6dfe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set environment variables for Python and Matplotlib
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV MPLCONFIGDIR=/app/.config/matplotlib
# Set the working directory inside the container
WORKDIR /app
# Install system dependencies required by OpenCV and other libraries
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the container at /app
COPY requirements.txt /app/
# Install the dependencies specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Create necessary directories and set proper permissions
RUN mkdir -p /app/uploads /app/static/uploads /app/static/results /tmp/flask_sessions /app/flask_sessions /app/models /app/.config/matplotlib && \
chmod -R 777 /app/uploads /app/static/uploads /app/static/results /tmp/flask_sessions /app/flask_sessions /app/models /app/.config/matplotlib
# Copy the entire application code to /app
COPY . /app/
# Expose the port used by the Flask app
EXPOSE 7860
# Set environment variables for Flask
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
ENV SESSION_FILE_DIR=/app/flask_sessions
# Run the application with Gunicorn, setting workers and timeout
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|