Spaces:
Running
Running
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim | |
# Set environment variables | |
ENV PYTHONDONTWRITEBYTECODE=1 \ | |
PYTHONUNBUFFERED=1 \ | |
PORT=7860 | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
build-essential \ | |
curl \ | |
git \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create a non-root user | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
ENV UVICORN_WS_PROTOCOL=websockets | |
# Set the working directory | |
WORKDIR $HOME/app | |
# Install uv using pip | |
RUN pip install --no-cache-dir uv | |
# Copy requirements first for better caching | |
COPY --chown=user requirements.txt . | |
COPY --chown=user pyproject.toml . | |
COPY --chown=user uv.lock . | |
# Install Python dependencies using uv | |
RUN pip install --no-cache-dir --upgrade pip | |
RUN uv sync | |
# Copy the application code | |
COPY --chown=user pregnancy_kb $HOME/app/pregnancy_kb | |
COPY --chown=user data $HOME/app/data | |
COPY --chown=user app.py . | |
COPY --chown=user chainlit.md . | |
COPY --chown=user .chainlit $HOME/app/.chainlit | |
COPY --chown=user .huggingface $HOME/app/.huggingface | |
# Expose the port | |
EXPOSE 7860 | |
# Command to run the application | |
CMD ["uv", "run", "chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"] |