Backend-healthcare / Dockerfile
MISSAOUI's picture
Update Dockerfile
4938104 verified
raw
history blame
912 Bytes
FROM python:3.12.4-slim
# Set environment variables for cache and Python
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
HF_HOME=/app/.cache/huggingface \
TRANSFORMERS_CACHE=/app/.cache/huggingface \
TORCH_HOME=/app/.cache/torch
# Create non-root user and set up directories
RUN useradd -m appuser && \
mkdir -p /app/.cache/huggingface /app/.cache/torch && \
chown -R appuser:appuser /app
WORKDIR /app
# Copy requirements first for better layer caching
COPY requirements.txt .
# Install dependencies as root
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY --chown=appuser:appuser . .
# Switch to non-root user
USER appuser
# Expose the port the app runs on
EXPOSE 7860
# Command to run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]