RespireX-Prototype / Dockerfile
CineDev's picture
Update Dockerfile
6753f90 verified
# Use an official Python runtime as a parent image
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set the working directory in the container
WORKDIR /app
# Install system dependencies required for packages like psycopg2, pillow, and pycairo
# Install system dependencies required for building Python packages like pycairo
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
python3-dev \
libcairo2-dev \
libpq-dev \
libpangocairo-1.0-0 \
libgdk-pixbuf-2.0-0 \
libffi-dev \
shared-mime-info \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the container
COPY requirements.txt /app/
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the backend application code
COPY . /app/
# Create a non-privileged user to run the app (required by some hosting environments)
RUN useradd -m myuser
USER myuser
# Expose the port the app runs on (Hugging Face Spaces typically use 7860)
EXPOSE 7860
# Command to run the application using Gunicorn (included in your requirements)
# Note: Using 0.0.0.0 is essential for container accessibility
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "respirex_backend.wsgi:application"]