Local development Environment
In this step you are going to install Docker, VS Code, and setup a DevContainer for your project.
Install Docker
MacOS and Windows should install Docker Desktop. Follow the instructions for MacOS or Windows
Choose your distribution and follow the steps on the Docker website
Verify your docker installation by running:
docker --versionInstall Visual Studio Code
Install Visual Studio Code via your preferred option, such as the Webpage or a package manager. Verify your installation by opening Visual Studio Code.
Create a simple DevContainer
- Open the command palette in Visual Studio Code by pressing
Ctrl+Shift+PorCmd+Shift+Pon MacOS. - Type
Dev Container: Add Dev Container Configuration Files...and select it.- Hint the search is fuzzy, so you can type
dev addand it should show up.
- Hint the search is fuzzy, so you can type
- When selecting the template, choose
Ubuntu, with the default settings. - Select the features you need, for example
Python, and pressOK- You can select
Keep Defaultsin don’t need a certain version or extra features & tools.
- You can select
- Done!
You should now see a .devcontainer folder in your project with a devcontainer.json file.
// For format details, see https://aka.ms/devcontainer.json. For config options, see the// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu{ "name": "Ubuntu", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/base:jammy", "features": { "ghcr.io/devcontainers/features/python:1": {} }
// Features to add to the dev container. More info: https://containers.dev/features. // "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created. // "postCreateCommand": "uname -a",
// Configure tool-specific properties. // "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root"}A popup should appear asking you to reopen the project in the DevContainer. Click Reopen in Container.
If not, open the command palette and type Dev Container: Reopen in Container.
Verify that you are in the DevContainer by opening a terminal in Visual Studio Code and running:
python --versionYou should see the Python version installed in the DevContainer:
vscode ➜ /workspaces/python-gh-actions $ python --versionPython 3.10.12