Skip to content

Commit

Permalink
chore: add devcontainer support to ease the setup of the dev workst…
Browse files Browse the repository at this point in the history
…ation with `python`, `ollama`, etc

When opening the project in `VSCode` or `IntellJ`, provided user has Docker installed and the **[DevContainer(https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)]**
This will automatically:

- Install Python 3
- Create the Venv `.source.venv` and print instructions to activate it
- (VSCodde) Automatically setup the Python Interpreter from the venv
- (VSCode) Install the `Jupyter` extension and enabled `Python` support
- Download and Start `Ollama Server`
- Pull some LLMs (`llama2` by defaut)
  • Loading branch information
tinesoft committed Jun 27, 2024
1 parent ad8c347 commit 77a1657
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "SFEIR School LangChain",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"upgradePackages": true,
"username": "automatic",
"userUid": "automatic",
"userGid": "automatic"
},
"ghcr.io/devcontainers/features/python:1": {
"installTools": true,
"installJupyterlab": true,
"version": "3.12"
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",

// Use 'postCreateCommand' to run commands after the container is started.
"postStartCommand": "./.devcontainer/postStartCommand.sh",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"mhutchie.git-graph",
"anweber.reveal-button",
"ms-python.python",
"ms-python.debugpy",
"ms-toolsai.jupyter"
],
"settings":{
"python.pythonPath": "./.school.venv/bin/python",
"debug.javascript.autoAttachFilter": "onlyWithFlag"
}
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
26 changes: 26 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

# Installing Node Modules
#npm ci

# Installing Ollama

echo "⬇️ Downloading and Installing Ollama Server..."
curl https://ollama.ai/install.sh | sh

# Create the virtual environment (if missing)
if [ ! -f .school.venv/bin/activate ]; then
echo "➕ Creating the virtual environment (.school.venv)..."
virtualenv .school.venv
fi

echo "✅ Setup done"

# Activate the virtual environment for this terminal session
echo ""
echo "Please don't forget to run the following command in your terminal..."
echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️"
echo "source .school.venv/bin/activate"
echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️"
echo "...(to activate the virtual env) before installing Python dependencies!"
echo ""
22 changes: 22 additions & 0 deletions .devcontainer/postStartCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Starting Ollama Server
echo "🏃🏿‍♂️ Starting Ollama Server..."
ollama serve &

echo "⬇️ Pulling LLMs..."
ollama pull llama2
#ollama pull mistral
#ollama pull codellama

echo "✅ Local LLMs Setup done!"


# Activate the virtual environment for this terminal session
echo ""
echo "Please don't forget to run the following command in your terminal..."
echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️"
echo "source .school.venv/bin/activate"
echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️"
echo "...(to activate the virtual env) before installing Python dependencies!"
echo ""
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ typings/
#Dev
docs/test.html

.venv*
.venv*
.school.venv

0 comments on commit 77a1657

Please sign in to comment.