11# Builder stage - use Debian Python image for building (onnxruntime needs glibc/manylinux)
2- FROM python:3.13-slim AS builder
2+ FROM dhi.io/python:3.13-dev AS builder
3+
4+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
35
46# Set environment variables
57ENV PYTHONDONTWRITEBYTECODE=1 \
68 PYTHONUNBUFFERED=1 \
79 UV_CACHE_DIR=/tmp/uv-cache \
810 UV_LINK_MODE=copy
911
10- # Install build dependencies
11- RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates && \
12- curl -LsSf https://astral.sh/uv/install.sh | sh && \
13- mv /root/.local/bin/uv /usr/local/bin/uv && \
14- rm -rf /var/lib/apt/lists/*
15-
1612# Set the working directory
1713WORKDIR /app
1814
@@ -23,7 +19,7 @@ COPY pyproject.toml uv.lock ./
2319RUN uv sync --frozen --no-dev
2420
2521# Final stage - use standard Debian slim (DHI too minimal for venv)
26- FROM python:3.13-slim
22+ FROM dhi.io/ python:3.13
2723
2824# Set environment variables
2925ENV PYTHONDONTWRITEBYTECODE=1 \
@@ -34,17 +30,10 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
3430WORKDIR /app
3531
3632# Copy virtual environment from builder
37- COPY --from=builder /app/.venv /app/.venv
33+ COPY --from=builder --chown=1000:1000 /app/.venv /app/.venv
3834
3935# Copy application code
40- COPY . .
41-
42- # Create non-root user
43- RUN groupadd -r -g 1000 chatbot && useradd -r -u 1000 -g chatbot chatbot && \
44- chown -R chatbot:chatbot /app
45-
46- # Run as non-root user
47- USER chatbot
36+ COPY chatbot.py chatbot.py
4837
4938# Run the application
5039CMD ["python" , "chatbot.py" ]
0 commit comments