Prevent mis-aligned environments between developers, onboard new-joiners faster, and reduce the time it takes to take your project to production. Sounds interesting? Devcontainers can help you with this. Devcontainers allow you to connect your IDE to a running Docker container and develop inside it. This gives you all the benefits of reproducibility that Docker is known for. In this talk, I will walk you through what Devcontainers are, why they might be useful for you, and how to create one for your Python project using VSCode.
Report
Share
Report
Share
1 of 42
Download to read offline
More Related Content
How to create a Devcontainer for your Python project
1. How to create a
Devcontainer for your
Python project 🐳
16. What is happening under the hood 🚗
BesidesstartingtheDockerimageandattachingtheterminaltoit,VSCodeisdoinga
couplemorethings:
1. isbeinginstalledonyourDevcontainer.
VSCodeServerisinstalledasaserviceinthecontaineritselfsoyourVSCode
installationcancommunicatewiththecontainer.
Forexample,installandrunextensions.
VSCodeServer
2.Configiscopiedover.
Configlike ~/.gitconfig and ~/.ssh/known_hosts arecopiedovertotheir
respectivelocationsinthecontainer.
3.Filesystemmounts.
VSCodeautomaticallytakescareofmounting:
ThefolderyouarerunningtheDevcontainerfrom.
YourVSCodeworkspacefolder.
17. Opening your Devcontainer with the click of a button
YourentireprojectsetupisnowencapsulatedintheDevcontainer.Soactuallywecanadd
aMarkdownbuttontoopenuptheDevcontainer:
JustmodifytheGitHubURLafter url= ✓.
[
![Open in Remote - Containers](
https://img.shields.io/static/v1?label=Remote%20-
%20Containers&message=Open&color=blue&logo=visualstudiocode
)
](
https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?
url=https://github.com/godatadriven/python-devcontainer-template
)
29. Running our CI in the Devcontainer
Therearetwobasicoptions:
1.BuildtheDockerimagewithintheCI/CDpipeline
2.Prebuildingtheimage
Let'sseeaboutoptionnumber(1).
30. 1. Build the Docker image within the CI/CD pipeline
Luckily,aGitHubActionwasalreadysetupforustodoexactlythis:
devcontainers/ci