Skip to content

Commit c6cb1fa

Browse files
authored
fix: devcontainer (#32260)
1 parent e42b1d2 commit c6cb1fa

File tree

3 files changed

+81
-24
lines changed

3 files changed

+81
-24
lines changed

.devcontainer/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ For more info, check out the [GitHub documentation](https://docs.github.com/en/f
2020

2121
[![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)
2222

23-
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:
24-
25-
```
26-
https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/<yourusername>/<yourclonedreponame>
23+
> [!NOTE]
24+
> 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:
2725
26+
```txt
27+
https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/&lt;YOUR_USERNAME&gt;/&lt;YOUR_CLONED_REPO_NAME&gt;
2828
```
2929

3030
Then you will have a local cloned repo where you can contribute and then create pull requests.
3131

32-
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.
32+
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.
3333

3434
Alternatively you can also follow these steps to open this repo in a container using the VS Code Dev Containers extension:
3535

.devcontainer/devcontainer.json

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,51 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
33
{
44
// Name for the dev container
5-
"name": "langchain",
6-
5+
"name": "langchain-py",
76
// Point to a Docker Compose file
87
"dockerComposeFile": "./docker-compose.yaml",
9-
108
// Required when using Docker Compose. The name of the service to connect to once running
11-
"service": "langchain",
12-
9+
"service": "langchain-py",
1310
// The optional 'workspaceFolder' property is the path VS Code should open by default when
1411
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
1512
"workspaceFolder": "/workspaces/langchain",
16-
1713
// Prevent the container from shutting down
18-
"overrideCommand": true
19-
14+
"overrideCommand": true,
2015
// Features to add to the dev container. More info: https://containers.dev/features
21-
// "features": {
22-
// "ghcr.io/devcontainers-contrib/features/poetry:2": {}
23-
// }
24-
16+
"features": {
17+
"ghcr.io/devcontainers/features/git:1": {},
18+
"ghcr.io/devcontainers/features/github-cli:1": {}
19+
},
2520
// Use 'forwardPorts' to make a list of ports inside the container available locally.
2621
// "forwardPorts": [],
27-
28-
// Uncomment the next line to run commands after the container is created.
29-
// "postCreateCommand": "cat /etc/os-release",
30-
22+
// Run commands after the container is created
23+
"postCreateCommand": "uv sync && echo 'LangChain (Python) dev environment ready!'",
3124
// Configure tool-specific properties.
32-
// "customizations": {},
33-
25+
"customizations": {
26+
"vscode": {
27+
"extensions": [
28+
"ms-python.python",
29+
"ms-python.debugpy",
30+
"ms-python.mypy-type-checker",
31+
"ms-python.isort",
32+
"unifiedjs.vscode-mdx",
33+
"davidanson.vscode-markdownlint",
34+
"ms-toolsai.jupyter",
35+
"GitHub.copilot",
36+
"GitHub.copilot-chat"
37+
],
38+
"settings": {
39+
"python.defaultInterpreterPath": ".venv/bin/python",
40+
"python.formatting.provider": "none",
41+
"[python]": {
42+
"editor.formatOnSave": true,
43+
"editor.codeActionsOnSave": {
44+
"source.organizeImports": true
45+
}
46+
}
47+
}
48+
}
49+
}
3450
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
3551
// "remoteUser": "root"
36-
}
52+
}

libs/langchain/dev.Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM python:3.11-slim-bookworm
2+
3+
# Set environment variables for Python and uv
4+
ENV PYTHONUNBUFFERED=1 \
5+
PYTHONDONTWRITEBYTECODE=1 \
6+
PIP_NO_CACHE_DIR=1 \
7+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
8+
UV_CACHE_DIR=/tmp/uv-cache
9+
10+
# Install system dependencies
11+
RUN apt-get update && apt-get install -y --no-install-recommends \
12+
build-essential \
13+
curl \
14+
git \
15+
vim \
16+
less \
17+
ca-certificates \
18+
&& rm -rf /var/lib/apt/lists/* \
19+
&& apt-get clean
20+
21+
RUN pip install --no-cache-dir uv
22+
23+
WORKDIR /workspaces/langchain
24+
25+
COPY . .
26+
27+
# Create uv cache directory and set permissions
28+
RUN mkdir -p $UV_CACHE_DIR && chmod 755 $UV_CACHE_DIR
29+
30+
# Install dependencies using uv (let uv handle the venv creation)
31+
RUN uv sync --dev
32+
33+
# Create a non-root user and set up proper permissions
34+
RUN useradd -m -s /bin/bash -u 1000 vscode && \
35+
chown -R vscode:vscode /workspaces $UV_CACHE_DIR
36+
37+
USER vscode
38+
39+
# Set shell for interactive use
40+
SHELL ["/bin/bash", "-c"]
41+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)