FROM python:3.11-alpine3.18
# Install required system dependencies for building Python packages
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates \
&& update-ca-certificates
# Set a working directory for the build
WORKDIR /workspace
# Copy only the core LangChain library package into the image
COPY libs/core /workspace/libs/core
# Build and install the package from source
WORKDIR /workspace/libs/core
RUN python -m ensurepip --upgrade >/dev/null 2>&1 || true \
&& pip install --no-cache-dir --upgrade pip setuptools wheel \
&& pip install --no-cache-dir .
# Create a small runtime check script to verify importability
RUN printf 'try:\n import langchain_core as lc\n print("OK", getattr(lc, "__name__", "langchain_core"))\nexcept Exception as e:\n print("ERR", e)\n raise\n' > /workspace/check_import.py
# Simple runtime check to ensure the package is importable
CMD ["python", "/workspace/check_import.py"]