pharma / Dockerfile
gsstec's picture
Upload 3 files
c18a41f verified
Raw
History Blame Contribute Delete
862 Bytes
FROM python:3.11-slim
# Set environment system variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HOME=/home/user
# Create app directory and safe system user
RUN useradd -m -u 1000 user
WORKDIR $HOME/app
# Install system dependencies if native extensions need compilation
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Switch to non-root privileges
USER user
ENV PATH=/home/user/.local/bin:$PATH
# Install Python requirements
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Copy application files
COPY --chown=user . .
# Hugging Face Spaces environment contract requires port 7860
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]