Skip to content

Commit a7989f3

Browse files
committed
add devcontainer configuration
Allows working with VSCode remote containers and Github CodeSpaces.
1 parent 5444cb8 commit a7989f3

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.3/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.10-bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
6+
7+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8+
ARG NODE_VERSION="none"
9+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10+
11+
RUN /usr/local/bin/python3 -m pip install --upgrade pip
12+
13+
COPY dev-requirements.txt /tmp/pip-tmp/requirements.txt
14+
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt && rm -rf /tmp/pip-tmp
15+
16+
COPY tox-requirements.txt /tmp/pip-tmp/requirements.txt
17+
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt && rm -rf /tmp/pip-tmp
18+
19+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
20+
&& apt-get -y install --no-install-recommends tig python2.7 python2.7-dev
21+
22+
# [Optional] Uncomment this line to install global node packages.
23+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.231.3/containers/python-3
3+
{
4+
"name": "Python 3",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"context": "..",
8+
"args": {
9+
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
10+
// Append -bullseye or -buster to pin to an OS version.
11+
// Use -bullseye variants on local on arm64/Apple Silicon.
12+
"VARIANT": "3.6-bullseye",
13+
// Options
14+
"NODE_VERSION": "lts/*"
15+
}
16+
},
17+
18+
"mounts": [
19+
// mount databricks config
20+
"source=${localEnv:HOME}/.databrickscfg,target=/home/vscode/.databrickscfg,type=bind,consistency=cached"
21+
],
22+
23+
// Set *default* container specific settings.json values on container create.
24+
"settings": {
25+
"python.defaultInterpreterPath": "/usr/local/bin/python",
26+
"python.linting.enabled": true,
27+
"python.linting.pylintEnabled": true,
28+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
29+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
30+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
31+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
32+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
33+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
34+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
35+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
36+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
37+
},
38+
39+
// Add the IDs of extensions you want installed when the container is created.
40+
"extensions": [
41+
"ms-python.python",
42+
"ms-python.vscode-pylance",
43+
"scala-lang.scala"
44+
],
45+
46+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
47+
// "forwardPorts": [],
48+
49+
// Use 'postCreateCommand' to run commands after the container is created.
50+
// "postCreateCommand": "pip3 install --user -r requirements.txt",
51+
52+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
53+
"remoteUser": "vscode"
54+
}

0 commit comments

Comments
 (0)