Medical-Chatbot-API / Dockerfile
khalednabawi11's picture
Update Dockerfile
dd4b311 verified
raw
history blame
872 Bytes
FROM python:3.9-slim
# Create a non-root user
RUN useradd -m appuser
# Set the working directory
WORKDIR /code
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements file and install Python dependencies
COPY app/requirements.txt .
RUN pip install --no-cache-dir -r app/requirements.txt
# Copy the application code
COPY app /code/app
COPY app/main.py .
# Create models and cache directories and set correct permissions
RUN mkdir -p /code/models/.cache/huggingface && \
chown -R appuser:appuser /code/models
# Set environment variables
ENV HOST=0.0.0.0
ENV PORT=7860
# Expose the port
EXPOSE 7860
# Switch to the non-root user
USER appuser
# Command to run the FastAPI app
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]