From 99f745b951660f144b4652fd665c0e2814d43ae7 Mon Sep 17 00:00:00 2001 From: Jay W Date: Mon, 2 Jun 2025 15:40:18 +0100 Subject: [PATCH] Fix Dockerfile --- Dockerfile | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd23820..43970b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,14 @@ RUN npm run build # Stage 2: Python Backend FROM docker.io/langchain/langgraph-api:3.11 +# -- Install UV -- +# First install curl, then install UV using the standalone installer +RUN apt-get update && apt-get install -y curl && \ + curl -LsSf https://astral.sh/uv/install.sh | sh && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +ENV PATH="/root/.local/bin:$PATH" +# -- End of UV installation -- + # -- Copy built frontend from builder stage -- # The app.py expects the frontend build to be at ../frontend/dist relative to its own location. # If app.py is at /deps/backend/src/agent/app.py, then ../frontend/dist resolves to /deps/frontend/dist. @@ -28,19 +36,28 @@ COPY --from=frontend-builder /app/frontend/dist /deps/frontend/dist # -- Adding local package . -- ADD backend/ /deps/backend # -- End of local package . -- - -# -- Installing all local dependencies -- -RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -c /api/constraints.txt -e /deps/backend + +# -- Installing all local dependencies using UV -- +# First, we need to ensure pip is available for UV to use +RUN uv pip install --system pip setuptools wheel +# Install dependencies with UV, respecting constraints +RUN cd /deps/backend && \ + PYTHONDONTWRITEBYTECODE=1 UV_SYSTEM_PYTHON=1 uv pip install --system -c /api/constraints.txt -e . # -- End of local dependencies install -- ENV LANGGRAPH_HTTP='{"app": "/deps/backend/src/agent/app.py:app"}' ENV LANGSERVE_GRAPHS='{"agent": "/deps/backend/src/agent/graph.py:graph"}' # -- Ensure user deps didn't inadvertently overwrite langgraph-api -RUN mkdir -p /api/langgraph_api /api/langgraph_runtime /api/langgraph_license && touch /api/langgraph_api/__init__.py /api/langgraph_runtime/__init__.py /api/langgraph_license/__init__.py +# Create all required directories that the langgraph-api package expects +RUN mkdir -p /api/langgraph_api /api/langgraph_runtime /api/langgraph_license /api/langgraph_storage && \ + touch /api/langgraph_api/__init__.py /api/langgraph_runtime/__init__.py /api/langgraph_license/__init__.py /api/langgraph_storage/__init__.py +# Use pip for this specific package as it has poetry-based build requirements RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir --no-deps -e /api # -- End of ensuring user deps didn't inadvertently overwrite langgraph-api -- -# -- Removing pip from the final image ~<:===~~~ -- -RUN pip uninstall -y pip setuptools wheel && rm -rf /usr/local/lib/python*/site-packages/pip* /usr/local/lib/python*/site-packages/setuptools* /usr/local/lib/python*/site-packages/wheel* && find /usr/local/bin -name "pip*" -delete +# -- Removing pip from the final image (but keeping UV) -- +RUN uv pip uninstall --system pip setuptools wheel && \ + rm -rf /usr/local/lib/python*/site-packages/pip* /usr/local/lib/python*/site-packages/setuptools* /usr/local/lib/python*/site-packages/wheel* && \ + find /usr/local/bin -name "pip*" -delete # -- End of pip removal -- -WORKDIR /deps/backend \ No newline at end of file +WORKDIR /deps/backend