petcare-api / Dockerfile
Sameer669
Initial PawCare Django backend with JWT auth, RBAC, audit logging, and HF storage
4f01198
# ──────────────────────────────────────────────────────────────────────────────
# PawCare Backend β€” Dockerfile for Hugging Face Spaces
# ──────────────────────────────────────────────────────────────────────────────
FROM python:3.11-slim
# System deps for Pillow & psycopg2
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev gcc libjpeg-dev zlib1g-dev libwebp-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python deps first (layer cache)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy project source
COPY . .
# Collect static files
RUN python manage.py collectstatic --noinput
# Create non-root user (HF Spaces runs as user 1000)
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 7860
# Gunicorn: 2 workers Γ— (2 Γ— CPU + 1) threads β€” suitable for HF free tier
CMD ["gunicorn", "petcare.wsgi:application", \
"--bind", "0.0.0.0:7860", \
"--workers", "2", \
"--threads", "4", \
"--timeout", "120", \
"--access-logfile", "-", \
"--error-logfile", "-"]