Skip to content

Commit c08db51

Browse files
committed
add devcontainer configuration
1 parent f6e6722 commit c08db51

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
4+
ARG VARIANT="3.12-bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/python:1-${VARIANT}
6+
7+
# Define the path to the virtualenv to work with
8+
ARG VENV_PATH="/home/vscode/venv"
9+
10+
COPY workshop/requirements.txt /tmp/pip-tmp/
11+
RUN su vscode -c "python -m venv /home/vscode/venv" \
12+
&& su vscode -c "${VENV_PATH}/bin/pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt" \
13+
&& rm -rf /tmp/pip-tmp \
14+
&& echo '\n# Path to your virtual environment\nVIRTUAL_ENV_PATH="/home/vscode/venv"\n\n# Activate the virtual environment if it exists\nif [ -d "$VIRTUAL_ENV_PATH" ]; then\n source "$VIRTUAL_ENV_PATH/bin/activate"\nfi\n' >> /home/vscode/.zshrc \
15+
&& echo '\n# Path to your virtual environment\nVIRTUAL_ENV_PATH="/home/vscode/venv"\n\n# Activate the virtual environment if it exists\nif [ -d "$VIRTUAL_ENV_PATH" ]; then\n source "$VIRTUAL_ENV_PATH/bin/activate"\nfi\n' >> /home/vscode/.bashrc

.devcontainer/devcontainer.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "Python 3",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"build": {
7+
"dockerfile": "Dockerfile",
8+
"context": "..",
9+
"args": {
10+
"VARIANT": "3.12-bullseye"
11+
}
12+
},
13+
// Features to add to the dev container. More info: https://containers.dev/features.
14+
// "features": {},
15+
16+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
17+
// "forwardPorts": [],
18+
19+
// Use 'postCreateCommand' to run commands after the container is created.
20+
//"postCreateCommand": ". /home/vscode/venv/bin/activate",
21+
22+
// Configure tool-specific properties.
23+
"customizations": {
24+
"codespaces": {
25+
"openFiles": [
26+
"workshop/README.md",
27+
"workshop/main.py",
28+
]
29+
},
30+
"vscode": {
31+
"settings": {
32+
"python.defaultInterpreterPath": "/home/vscode/venv/bin/python",
33+
"python.terminal.activateEnvInCurrentTerminal": true,
34+
"terminal.integrated.cwd": "workshop",
35+
"workbench.editorAssociations": {
36+
"*.md": "vscode.markdown.preview.editor"
37+
}
38+
},
39+
"extensions": [
40+
"ms-python.python",
41+
"ms-python.vscode-pylance",
42+
"GitHub.copilot"
43+
]
44+
}
45+
}
46+
47+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
48+
// "remoteUser": "root"
49+
}

0 commit comments

Comments
 (0)