Skip to content

Add Dev Container support that installs Python 3.11, Java 11.0.25-sem, Maven, LLVM (for C), and Rust. #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Image for a Python 3 development environment
FROM python:3.11-bookworm

# Turn off interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Add any Python tools that are needed beyond Python 3.11
RUN apt-get update && \
apt-get install -y sudo build-essential lsb-release software-properties-common ca-certificates \
python3.11-dev python3.11-venv libxmlsec1-dev gnupg gcc vim make git zip tree curl wget jq

# Add LLVM for C support with symlinks
RUN wget https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh 18 && \
apt-get install -y llvm-18 llvm-18-dev clang-18 libclang-18-dev && \
ln -s /usr/bin/clang-18 /usr/bin/clang && \
ln -s /usr/bin/llvm-config-18 /usr/bin/llvm-config

# Install Ollama
# RUN curl -fsSL https://ollama.com/install.sh | sh

# Create a user for development
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user with passwordless sudo privileges
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
&& usermod -aG sudo $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Set up the Python development environment
WORKDIR /python-sdk
RUN python3 -m pip install --upgrade pip wheel && \
pip3 install poetry==1.8.5

# Enable color terminal for docker exec bash
ENV TERM=xterm-256color

# Become a regular user
USER $USERNAME

# Add Java dependencies with SDKMan as a regular user
ARG HOME="/home/$USERNAME"
RUN curl -s "https://get.sdkman.io" | bash
# this SHELL command is needed to allow using source
SHELL ["/bin/bash", "-c"]
RUN source "$HOME/.sdkman/bin/sdkman-init.sh" && \
sdk install java 11.0.25-sem && \
sdk use java 11.0.25-sem && \
sdk install maven

# Add Rust support
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh && \
sh /tmp/rustup.sh -y && \
rm /tmp/rustup.sh
71 changes: 71 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "CLDK Python SDK",
"dockerFile": "Dockerfile",
"context": "..",
"remoteUser": "vscode",
"workspaceFolder": "/python-sdk",
"workspaceMount": "source=${localWorkspaceFolder},target=/python-sdk,type=bind,consistency=delegated",
// "mounts": [
// "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ollama,target=/home/vscode/.ollama,type=bind,consistency=cached"
// ],
"runArgs": ["-h", "codellm-devkit", "--name", "python-sdk"],
"customizations": {
"vscode": {
"settings": {
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"git.mergeEditor": true,
"autoDocstring.docstringFormat": "google",
"markdown-preview-github-styles.colorTheme": "light",
"makefile.extensionOutputFolder": "/tmp",
"python.terminal.activateEnvironment": true,
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"tests"
],
"cSpell.words": [
"pydantic",
"pyarrow",
"cldk",
"Codeanalyzer",
"treesitter"
],
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/*.pyc": true,
"**/__pycache__": true,
"**/.pytest_cache": true
}
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-python.debugpy",
"ms-python.pylint",
"ms-python.flake8",
"ms-python.black-formatter",
"zeshuaro.vscode-python-poetry",
"njpwerner.autodocstring",
"wholroyd.jinja",
"yzhang.markdown-all-in-one",
"hnw.vscode-auto-open-markdown-preview",
"davidanson.vscode-markdownlint",
"bierner.markdown-preview-github-styles",
"tamasfe.even-better-toml",
"donjayamanne.githistory",
"GitHub.vscode-pull-request-github",
"hbenl.vscode-test-explorer",
"LittleFoxTeam.vscode-python-test-adapter",
"redhat.vscode-yaml",
"ms-azuretools.vscode-docker",
"streetsidesoftware.code-spell-checker"
]
}
},
"postCreateCommand": "sudo poetry config virtualenvs.create false && sudo poetry install; echo '---'; python3 --version; echo '---'; java -version; echo '---'; mvn --version; echo '--'; clang --version; echo '---';"
}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ Before we begin, make sure you have the following prerequisites installed:
* Python 3.11 or later
* Ollama v0.3.4 or later

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.

Use the following commands:

```bash
git clone https://github.com/codellm-devkit/python-sdk.git
cd python-dsk
code .
```

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.

### Step 1: Set up an Ollama server

If don't already have ollama, please download and install it from here: [Ollama](https://ollama.com/download).
Expand Down
40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.