PaySim-Fraud / Dockerfile
Nickanas's picture
Upload 24 files
71c85a4 verified
Raw History Blame Contribute Delete
1.1 kB
# 1. Lightweight Python matching the dev version
FROM python:3.13-slim
# 2. Run as a non-root user. Hugging Face Spaces run containers as UID 1000;
# creating a matching user with a writable home avoids permission errors.
# (This is also good security practice for AWS / Docker Hub.)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# 3. Working directory inside the user's home
WORKDIR /home/user/app
# 4. Copy the serving dependency file first (better layer caching)
COPY --chown=user requirements-serve.txt .
# 5. Install CPU-only torch, then the serving-only dependencies
RUN pip install --user --upgrade pip \
&& pip install --user torch --index-url https://download.pytorch.org/whl/cpu \
&& pip install --user -r requirements-serve.txt
# 6. Copy the project (including artifacts/, needed to serve)
COPY --chown=user . .
# 7. Unbuffered logs + make `src` importable
ENV PYTHONUNBUFFERED=1 \
PYTHONPATH=/home/user/app
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "src.app.main:app", "--host", "0.0.0.0", "--port", "8000"]