From 5f6763ee1534a9998bcb2fbcec0c8e8ab7e43d96 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Tue, 5 Sep 2023 16:09:34 -0700 Subject: [PATCH 1/6] dev container for lsp --- .devcontainer/Dockerfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..0dd5fc5 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,16 @@ +FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/base:bookworm + +RUN apt-get install -y wget bzip2 + +# Run in silent mode and save downloaded script as anaconda.sh. +# Run with /bin/bash and run in silent mode to /opt/conda. +# Also get rid of installation script after finishing. +RUN wget --quiet https://repo.anaconda.com/archive/Anaconda3-2023.07-1-Linux-x86_64.sh -O ~/anaconda.sh && \ + /bin/bash ~/anaconda.sh -b -p /opt/conda && \ + rm ~/anaconda.sh + +ENV PATH="/opt/conda/bin:$PATH" + +# Sudo apt update needs to run in order for installation of fish to work . +RUN sudo apt update && \ + sudo apt install fish -y From f7d37fa1215023a554e23ec87b94a80f0d489cb4 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Tue, 5 Sep 2023 17:36:19 -0700 Subject: [PATCH 2/6] remove conda --- .devcontainer/Dockerfile | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0dd5fc5..3dfb5d0 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,15 +1,5 @@ FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/base:bookworm -RUN apt-get install -y wget bzip2 - -# Run in silent mode and save downloaded script as anaconda.sh. -# Run with /bin/bash and run in silent mode to /opt/conda. -# Also get rid of installation script after finishing. -RUN wget --quiet https://repo.anaconda.com/archive/Anaconda3-2023.07-1-Linux-x86_64.sh -O ~/anaconda.sh && \ - /bin/bash ~/anaconda.sh -b -p /opt/conda && \ - rm ~/anaconda.sh - -ENV PATH="/opt/conda/bin:$PATH" # Sudo apt update needs to run in order for installation of fish to work . RUN sudo apt update && \ From 4c93662eff5418711eaef777468496c7b00703ac Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 6 Sep 2023 13:49:56 -0700 Subject: [PATCH 3/6] add on, post create for python and requirement --- .devcontainer/Dockerfile | 1 - .devcontainer/devcontainer.json | 12 ++++++++---- scripts/onCreateCommand.sh | 25 +++++++++++++++++++++++++ scripts/postCreateCommand.sh | 3 +++ 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 scripts/onCreateCommand.sh create mode 100644 scripts/postCreateCommand.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3dfb5d0..6854d30 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,5 @@ FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/base:bookworm - # Sudo apt update needs to run in order for installation of fish to work . RUN sudo apt update && \ sudo apt install fish -y diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f33faf1..6b0dac3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" }, @@ -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" } \ No newline at end of file diff --git a/scripts/onCreateCommand.sh b/scripts/onCreateCommand.sh new file mode 100644 index 0000000..fa70b23 --- /dev/null +++ b/scripts/onCreateCommand.sh @@ -0,0 +1,25 @@ +#!/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 +# echo 'eval "$(pyenv init -)"' >> ~/.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 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 + diff --git a/scripts/postCreateCommand.sh b/scripts/postCreateCommand.sh new file mode 100644 index 0000000..805c353 --- /dev/null +++ b/scripts/postCreateCommand.sh @@ -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 \ No newline at end of file From a67c2f8fbfdc0190027d314c24e215097f44ca7b Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 6 Sep 2023 14:40:10 -0700 Subject: [PATCH 4/6] add install for Rust and Cargo --- scripts/onCreateCommand.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/onCreateCommand.sh b/scripts/onCreateCommand.sh index fa70b23..f867da4 100644 --- a/scripts/onCreateCommand.sh +++ b/scripts/onCreateCommand.sh @@ -4,13 +4,16 @@ 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 -# echo 'eval "$(pyenv init -)"' >> ~/.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 From bc3e8efec6e2e6baa2cdafc9e77b0bc1ff7a417c Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 6 Sep 2023 14:53:48 -0700 Subject: [PATCH 5/6] remove platform specific flag --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6854d30..a7c6c62 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/base:bookworm +FROM mcr.microsoft.com/devcontainers/base:bookworm # Sudo apt update needs to run in order for installation of fish to work . RUN sudo apt update && \ From df15cba72a8a1dd4a096fd8efadd6fef5dbf80ce Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 6 Sep 2023 15:25:31 -0700 Subject: [PATCH 6/6] add missing packages from pyenv --- .devcontainer/Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a7c6c62..dbe2fa1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,8 @@ FROM mcr.microsoft.com/devcontainers/base:bookworm +RUN sudo apt update -# Sudo apt update needs to run in order for installation of fish to work . -RUN sudo apt update && \ - sudo apt install fish -y +# 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 \ No newline at end of file