diff --git a/.devcontainer/README.md b/.devcontainer/README.md index c439064d2ce..5c05c844439 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -20,16 +20,16 @@ For more info, check out the [GitHub documentation](https://docs.github.com/en/f [![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/langchain-ai/langchain) -Note: If you click the link above you will open the main repo (langchain-ai/langchain) and not your local cloned repo. This is fine if you only want to run and test the library, but if you want to contribute you can use the link below and replace with your username and cloned repo name: - -``` -https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com// +> [!NOTE] +> If you click the link above you will open the main repo (`langchain-ai/langchain`) and *not* your local cloned repo. This is fine if you only want to run and test the library, but if you want to contribute you can use the link below and replace with your username and cloned repo name: +```txt +https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/<YOUR_USERNAME>/<YOUR_CLONED_REPO_NAME> ``` Then you will have a local cloned repo where you can contribute and then create pull requests. -If you already have VS Code and Docker installed, you can use the button above to get started. This will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use. +If you already have VS Code and Docker installed, you can use the button above to get started. This will use VSCode to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use. Alternatively you can also follow these steps to open this repo in a container using the VS Code Dev Containers extension: diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 48c58f7bcfc..dd51b49b021 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,35 +2,51 @@ // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose { // Name for the dev container - "name": "langchain", - + "name": "langchain-py", // Point to a Docker Compose file "dockerComposeFile": "./docker-compose.yaml", - // Required when using Docker Compose. The name of the service to connect to once running - "service": "langchain", - + "service": "langchain-py", // The optional 'workspaceFolder' property is the path VS Code should open by default when // connected. This is typically a file mount in .devcontainer/docker-compose.yml "workspaceFolder": "/workspaces/langchain", - // Prevent the container from shutting down - "overrideCommand": true - + "overrideCommand": true, // Features to add to the dev container. More info: https://containers.dev/features - // "features": { - // "ghcr.io/devcontainers-contrib/features/poetry:2": {} - // } - + "features": { + "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], - - // Uncomment the next line to run commands after the container is created. - // "postCreateCommand": "cat /etc/os-release", - + // Run commands after the container is created + "postCreateCommand": "uv sync && echo 'LangChain (Python) dev environment ready!'", // Configure tool-specific properties. - // "customizations": {}, - + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.debugpy", + "ms-python.mypy-type-checker", + "ms-python.isort", + "unifiedjs.vscode-mdx", + "davidanson.vscode-markdownlint", + "ms-toolsai.jupyter", + "GitHub.copilot", + "GitHub.copilot-chat" + ], + "settings": { + "python.defaultInterpreterPath": ".venv/bin/python", + "python.formatting.provider": "none", + "[python]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + } + } + } + } // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" -} +} \ No newline at end of file diff --git a/libs/langchain/dev.Dockerfile b/libs/langchain/dev.Dockerfile new file mode 100644 index 00000000000..ec0c297cdc3 --- /dev/null +++ b/libs/langchain/dev.Dockerfile @@ -0,0 +1,41 @@ +FROM python:3.11-slim-bookworm + +# Set environment variables for Python and uv +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + UV_CACHE_DIR=/tmp/uv-cache + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + curl \ + git \ + vim \ + less \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* \ + && apt-get clean + +RUN pip install --no-cache-dir uv + +WORKDIR /workspaces/langchain + +COPY . . + +# Create uv cache directory and set permissions +RUN mkdir -p $UV_CACHE_DIR && chmod 755 $UV_CACHE_DIR + +# Install dependencies using uv (let uv handle the venv creation) +RUN uv sync --dev + +# Create a non-root user and set up proper permissions +RUN useradd -m -s /bin/bash -u 1000 vscode && \ + chown -R vscode:vscode /workspaces $UV_CACHE_DIR + +USER vscode + +# Set shell for interactive use +SHELL ["/bin/bash", "-c"] +CMD ["/bin/bash"] \ No newline at end of file