MogensR's picture
Create docker/Dockerfile.cpu
ad0434e
raw
history blame
1.46 kB
# ============================================================================
# CPU-only Dockerfile for BackgroundFX Pro
# For development, testing, or CPU-only deployments
# ============================================================================
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive \
DEVICE=cpu \
OMP_NUM_THREADS=4
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git wget curl \
ffmpeg \
libsm6 libxext6 libxrender1 libgl1-mesa-glx \
libglib2.0-0 libgomp1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies
COPY requirements-cpu.txt requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir \
torch==2.1.0 --index-url https://download.pytorch.org/whl/cpu \
torchvision==0.16.0 --index-url https://download.pytorch.org/whl/cpu && \
pip install --no-cache-dir -r requirements.txt
# Create app user
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
# Copy application
COPY --chown=appuser:appuser . .
# Create directories
RUN mkdir -p logs uploads outputs models/.cache
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
EXPOSE 7860 8000
CMD ["python", "-u", "app.py"]