Skip to content
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

Dev Container for lsprotocol #267

Merged
merged 6 commits into from
Sep 7, 2023
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
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/devcontainers/base:bookworm
RUN sudo apt update

# Pyenv installation of Python versions is missing below packages.
RUN sudo apt install libbz2-dev libncurses5-dev libffi-dev libreadline-dev libsqlite3-dev liblzma-dev -y

# Install fish.
RUN sudo apt install fish -y
12 changes: 8 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
"features": {
"name": "LSP Dev Container",
"build": {
"dockerfile": "./Dockerfile",
"context": ".."
},
"features": {
"ghcr.io/devcontainers/features/powershell:1": {
"version": "latest"
},
Expand All @@ -20,5 +23,6 @@
]
}
},
"postCreateCommand": "python -m pip install nox && python -m pip install -r ./packages/python/requirements.txt -r ./requirements.txt"
"onCreateCommand": "bash scripts/onCreateCommand.sh",
"postCreateCommand": "bash scripts/postCreateCommand.sh"
}
28 changes: 28 additions & 0 deletions scripts/onCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Install pyenv and Python versions here to avoid using shim.
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc

export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
# eval "$(pyenv init -)" Comment this out and DO NOT use shim.
source ~/.bashrc

# Install Rust and Cargo
curl https://sh.rustup.rs -sSf | bash -s -- -y
echo 'source $HOME/.cargo/env' >> ~/.bashrc

# Install Python via pyenv .
pyenv install 3.8:latest 3.9:latest 3.10:latest 3.11:latest

# Set default Python version to 3.8 .
pyenv global 3.8.18

# Create Virutal environment.
pyenv exec python3.8 -m venv .venv

# Activate Virtual environment.
source /workspaces/lsprotocol/.venv/bin/activate

3 changes: 3 additions & 0 deletions scripts/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source /workspaces/lsprotocol/.venv/bin/activate
python -m pip install nox
python -m pip install -r ./packages/python/requirements.txt -r ./requirements.txt