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 VS Code Python Extension #21435

Merged
merged 7 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
26 changes: 26 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This image will serve as a starting point for devcontainer.json.
# Get latest image of Fedora as the base image.
FROM docker.io/library/fedora:latest

# Install supported python versions and nodejs.
RUN dnf -y --nodocs install /usr/bin/{python3.7,python3.8,python3.9,python3.10,python3.11,git,gcc,conda} && \
dnf clean all

ENV NVM_VERSION=0.39.3
ENV NODE_VERSION=16.17.1
ENV NPM_VERSION=8.19.3

# Installation instructions from https://github.com/nvm-sh/nvm .
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash
RUN export NVM_DIR="$HOME/.nvm" && \
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && \
nvm install $NODE_VERSION && \
npm install -g npm@$NPM_VERSION

# For clean open source builds.
ENV DISABLE_TRANSLATIONS=true




29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "VS Code Python Dev Container",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"build": {
"dockerfile": "./Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"extensions": [
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"ms-python.python",
"ms-python.black-formatter",
"ms-python.vscode-pylance",
"charliermarsh.ruff"
]
}
},
// Commands to execute on container creation,start.
"postCreateCommand": "bash scripts/postCreateCommand.sh",
// Environment variable placed inside containerEnv following: https://containers.dev/implementors/json_reference/#general-properties
"containerEnv": {
"CI_PYTHON_PATH": "/workspaces/vscode-python/.venv/bin/python"
}

}
15 changes: 15 additions & 0 deletions scripts/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
npm ci
# Create Virutal environment.
python3.7 -m venv /workspaces/vscode-python/.venv

# Activate Virtual environment.
source /workspaces/vscode-python/.venv/bin/activate

# Install required Python libraries.
npx gulp installPythonLibs

# Install testing requirement using python in .venv .
/workspaces/vscode-python/.venv/bin/python -m pip install -r build/test-requirements.txt
/workspaces/vscode-python/.venv/bin/python -m pip install -r build/smoke-test-requirements.txt
/workspaces/vscode-python/.venv/bin/python -m pip install -r build/functional-test-requirements.txt