10000 Merge pull request #103 from codellm-devkit/add-devcontainer · codellm-devkit/python-sdk@90d4dc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 90d4dc0

Browse files
authored
Merge pull request #103 from codellm-devkit/add-devcontainer
Add Dev Container support that installs Python 3.11, Java 11.0.25-sem, Maven, LLVM (for C), and Rust.
2 parents 4105005 + 964be40 commit 90d4dc0

File tree

4 files changed

+162
-20
lines changed

4 files changed

+162
-20
lines changed

.devcontainer/Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Image for a Python 3 development environment
2+
FROM python:3.11-bookworm
3+
4+
# Turn off interactive prompts
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Add any Python tools that are needed beyond Python 3.11
8+
RUN apt-get update && \
9+
apt-get install -y sudo build-essential lsb-release software-properties-common ca-certificates \
10+
python3.11-dev python3.11-venv libxmlsec1-dev gnupg gcc vim make git zip tree curl wget jq
11+
12+
# Add LLVM for C support with symlinks
13+
RUN wget https://apt.llvm.org/llvm.sh && \
14+
chmod +x llvm.sh && \
15+
./llvm.sh 18 && \
16+
apt-get install -y llvm-18 llvm-18-dev clang-18 libclang-18-dev && \
17+
ln -s /usr/bin/clang-18 /usr/bin/clang && \
18+
ln -s /usr/bin/llvm-config-18 /usr/bin/llvm-config
19+
20+
# Install Ollama
21+
# RUN curl -fsSL https://ollama.com/install.sh | sh
22+
23+
# Create a user for development
24+
ARG USERNAME=vscode
25+
ARG USER_UID=1000
26+
ARG USER_GID=$USER_UID
27+
28+
# Create the user with passwordless sudo privileges
29+
RUN groupadd --gid $USER_GID $USERNAME \
30+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
31+
&& usermod -aG sudo $USERNAME \
32+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
33+
&& chmod 0440 /etc/sudoers.d/$USERNAME
34+
35+
# Set up the Python development environment
36+
WORKDIR /python-sdk
37+
RUN python3 -m pip install --upgrade pip wheel && \
38+
pip3 install poetry==1.8.5
39+
40+
# Enable color terminal for docker exec bash
41+
ENV TERM=xterm-256color
42+
43+
# Become a regular user
44+
USER $USERNAME
45+
46+
# Add Java dependencies with SDKMan as a regular user
47+
ARG HOME="/home/$USERNAME"
48+
RUN curl -s "https://get.sdkman.io" | bash
49+
# this SHELL command is needed to allow using source
50+
SHELL ["/bin/bash", "-c"]
51+
RUN source "$HOME/.sdkman/bin/sdkman-init.sh" && \
52+
sdk install java 11.0.25-sem && \
53+
sdk use java 11.0.25-sem && \
54+
sdk install maven
55+
56+
# Add Rust support
57+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh && \
58+
sh /tmp/rustup.sh -y && \
59+
rm /tmp/rustup.sh

.devcontainer/devcontainer.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"name": "CLDK Python SDK",
3+
"dockerFile": "Dockerfile",
4+
"context": "..",
5+
"remoteUser": "vscode",
6+
"workspaceFolder": "/python-sdk",
7+
"workspaceMount": "source=${localWorkspaceFolder},target=/python-sdk,type=bind,consistency=delegated",
8+
// "mounts": [
9+
// "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ollama,target=/home/vscode/.ollama,type=bind,consistency=cached"
10+
// ],
11+
"runArgs": ["-h", "codellm-devkit", "--name", "python-sdk"],
12+
"customizations": {
13+
"vscode": {
14+
"settings": {
15+
"[python]": {
16+
"editor.defaultFormatter": "ms-python.black-formatter",
17+
"editor.formatOnSave": true
18+
},
19+
"git.mergeEditor": true,
20+
"autoDocstring.docstringFormat": "google",
21+
"markdown-preview-github-styles.colorTheme": "light",
22+
"makefile.extensionOutputFolder": "/tmp",
23+
"python.terminal.activateEnvironment": true,
24+
"python.testing.unittestEnabled": false,
25+
"python.testing.pytestEnabled": true,
26+
"python.testing.pytestArgs": [
27+
"tests"
28+
],
29+
"cSpell.words": [
30+
"pydantic",
31+
"pyarrow",
32+
"cldk",
33+
"Codeanalyzer",
34+
"treesitter"
35+
],
36+
"files.exclude": {
37+
"**/.git": true,
38+
"**/.DS_Store": true,
39+
"**/*.pyc": true,
40+
"**/__pycache__": true,
41+
"**/.pytest_cache": true
42+
}
43+
},
44+
"extensions": [
45+
"ms-python.python",
46+
"ms-python.vscode-pylance",
47+
"ms-toolsai.jupyter",
48+
"ms-python.debugpy",
49+
"ms-python.pylint",
50+
"ms-python.flake8",
51+
"ms-python.black-formatter",
52+
"zeshuaro.vscode-python-poetry",
53+
"njpwerner.autodocstring",
54+
"wholroyd.jinja",
55+
"yzhang.markdown-all-in-one",
56+
"hnw.vscode-auto-open-markdown-preview",
57+
"davidanson.vscode-markdownlint",
58+
"bierner.markdown-preview-github-styles",
59+
"tamasfe.even-better-toml",
60+
"donjayamanne.githistory",
61+
"GitHub.vscode-pull-request-github",
62+
"hbenl.vscode-test-explorer",
63+
"LittleFoxTeam.vscode-python-test-adapter",
64+
"redhat.vscode-yaml",
65+
"ms-azuretools.vscode-docker",
66+
"streetsidesoftware.code-spell-checker"
67+
]
68+
}
69+
},
70+
"postCreateCommand": "sudo poetry config virtualenvs.create false && sudo poetry install; echo '---'; python3 --version; echo '---'; java -version; echo '---'; mvn --version; echo '--'; clang --version; echo '---';"
71+
}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ Before we begin, make sure you have the following prerequisites installed:
122122
* Python 3.11 or later
123123
* Ollama v0.3.4 or later
124124

125+
If you are using [Visual Studio Code](https://code.visualstudio.com) with the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension along with [Docker Desktop](https://www.docker.com/products/docker-desktop) or [Rancher Desktop](https://w3.ibm.com/w3publisher/docker-desktop/rancher-desktop), this project contains a Dev Container environment for you to develop in.
126+
127+
Use the following commands:
128+
129+
```bash
130+
git clone https://github.com/codellm-devkit/python-sdk.git
131+
cd python-dsk
132+
code .
133+
```
134+
135+
When Visual Studio Code starts, select the option to **Reopen in Container** and a development environment with Python, Java, C, and Rust will be available to you. See [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers) for more detailed instructions.
136+
125137
### Step 1: Set up an Ollama server
126138

127139
If don't already have ollama, please download and install it from here: [Ollama](https://ollama.com/download).

poetry.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0