contentai / Dockerfile
webmazta
Add Docker app setup
cecad47
Raw History Blame Contribute Delete
1.11 kB
# Use an official Python runtime as a parent image
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
# Install system dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update --fix-missing && apt-get install -y --no-install-recommends \
ffmpeg \
libgl1 \
libglib2.0-0 \
libnss3 \
dnsutils \
ca-certificates \
curl \
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code (excluding .hfignore patterns)
COPY . .
# Create persistent data directory
RUN mkdir -p /data && chmod 777 /data
# Expose the port the app runs on
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -fsS "http://127.0.0.1:${PORT}/health" || exit 1
# Run the application
CMD ["sh", "-c", "gunicorn app:app --bind 0.0.0.0:${PORT:-7860} --timeout 900 --workers 1"]