Skip to content

Commit 32dcd7f

Browse files
authored
🔨 VSCode + Devcontainer support (MarlinFirmware#22420)
1 parent 1d06fe8 commit 32dcd7f

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

‎.devcontainer/Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
4+
ARG VARIANT="3.9.0-buster"
5+
FROM python:${VARIANT}
6+
7+
# [Option] Install Node.js
8+
ARG INSTALL_NODE="true"
9+
ARG NODE_VERSION="lts/*"
10+
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
11+
12+
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
13+
# COPY requirements.txt /tmp/pip-tmp/
14+
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
15+
# && rm -rf /tmp/pip-tmp
16+
17+
# [Optional] Uncomment this section to install additional OS packages.
18+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
19+
# && apt-get -y install --no-install-recommends <your-package-list-here>
20+
21+
# [Optional] Uncomment this line to install global node packages.
22+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
23+
24+
25+
RUN pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
26+
RUN platformio update
27+
# To get the test platforms
28+
RUN pip install PyYaml
29+
#ENV PATH /code/buildroot/bin/:/code/buildroot/tests/:${PATH}

‎.devcontainer/devcontainer.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.187.0/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.6, 3.7, 3.8, 3.9
10+
"VARIANT": "3.9.0-buster",
11+
// Options
12+
"INSTALL_NODE": "false",
13+
"NODE_VERSION": "lts/*"
14+
}
15+
},
16+
17+
// Set *default* container specific settings.json values on container create.
18+
"settings": {
19+
"python.pythonPath": "/usr/local/bin/python",
20+
"python.languageServer": "Pylance",
21+
"python.linting.enabled": true,
22+
"python.linting.pylintEnabled": true,
23+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
24+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
25+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
26+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
27+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
28+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
29+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
30+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
31+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
32+
},
33+
34+
// Add the IDs of extensions you want installed when the container is created.
35+
"extensions": [
36+
"ms-python.python",
37+
"ms-python.vscode-pylance",
38+
"platformio.platformio-ide",
39+
"marlinfirmware.auto-build",
40+
"editorconfig.editorconfig"
41+
],
42+
43+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
44+
// "forwardPorts": [],
45+
46+
// Use 'postCreateCommand' to run commands after the container is created.
47+
// "postCreateCommand": "pip3 install --user -r requirements.txt",
48+
49+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
50+
// "remoteUser": "vscode"
51+
}

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ To build and upload Marlin you will use one of these tools:
3535

3636
- The free [Visual Studio Code](https://code.visualstudio.com/download) using the [Auto Build Marlin](https://marlinfw.org/docs/basics/auto_build_marlin.html) extension.
3737
- The free [Arduino IDE](https://www.arduino.cc/en/main/software) : See [Building Marlin with Arduino](https://marlinfw.org/docs/basics/install_arduino.html)
38+
- You can also use VSCode with devcontainer : See [Installing Marlin (VSCode devcontainer)](http://marlinfw.org/docs/basics/install_devcontainer_vscode.html).
3839

3940
Marlin is optimized to build with the **PlatformIO IDE** extension for **Visual Studio Code**. You can still build Marlin with **Arduino IDE**, and we hope to improve the Arduino build experience, but at this time PlatformIO is the better choice.
4041

0 commit comments

Comments
 (0)