Recommended way to manage dockerfile with Visual Studio Code

Hi,

I’m slowly making my way through the learning process of using containers for development. My application will run a multi-container setup with a weston container as the wayland server and another container for my app. The weston container is started through the docker-compose file in the project, what I’m having trouble with is managing the dockerfile for the app container.

All the examples in the Torizon Samples repository have separate dockerfiles that are neatly organized. On the other hand Visual Studio Code only has a few templates for Python apps and are all based on QT images which is a small problem, as my app is based on OpenCV.

What would be the recommended or normal way to manage such a situation?

Thanks!

PS: Please excuse any incorrect uses of the terminology.

Greeting @alexxs,

As an initial reference I would recommend this article on Python development with our VSCode extension: Python Development and Debugging on TorizonCore Using Visual Studio Code | Toradex Developer Center

Just to clarify how the extension works. When you create a project it will auto-generate a Dockerfile template depending on the project, as you’ve already noticed. By the way there should be a project type to generate a non-Qt focused Python project. This is shown in more detail in the article I linked.

Then using the extension you can modify the auto-generated Dockerfile and add packages and other commands. As a side-note please don’t manually edit the Dockerfile that is auto-generated by the extension. This will just result in your changes being overwritten as the Dockerfile is completely auto-generated. Instead use the configuration options made available via the extension.

However you’re also free at any time to just copy the Dockerfile that gets auto-generated and manage it outside of the VSCode environment. Do note that there’s a separate Dockerfile for debug and release states.

I hope this helped clear things up.

Best Regards,
Jeremias

This is perfectly clear, thanks! If I decide to manage the Dockerfile on my own, could you tell me how to specify which Dockerfile is being used by the project?

Thanks!
Alex

Well if you replace the contents of the project’s Dockerfile with your own this would “work”. However once you build the project it will overwrite the Dockerfile contents based on the project’s configuration. Currently there’s no nice way to do this without breaking how the extension works.

Best Regards,
Jeremias

1 Like