Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

[PATCH] Add minimal devcontainer

83 views
Skip to first unread message

toe...@gmail.com

unread,
Dec 25, 2024, 12:22:02 PM12/25/24
to swup...@googlegroups.com, ayoub...@googlemail.com, stefan...@swupdate.org, ungerer...@gmail.com, Mark Jonas, Ayoub Zaki
From: Mark Jonas <toe...@gmail.com>

The devcontainer can build and run all SWupdate tests for x86-64
targets. It uses ci/setup.sh to install the required build dependencies.

Suggested-by: Ayoub Zaki <ayoub...@embetrix.com>
Signed-off-by: Mark Jonas <toe...@gmail.com>
---
.devcontainer/Dockerfile | 33 +++++++++++++++++++++++++++++++++
.devcontainer/devcontainer.json | 13 +++++++++++++
.gitignore | 3 +++
DevContainer.md | 26 ++++++++++++++++++++++++++
4 files changed, 75 insertions(+)
create mode 100644 .devcontainer/Dockerfile
create mode 100644 .devcontainer/devcontainer.json
create mode 100644 DevContainer.md

diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 00000000..e0f6d84e
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,33 @@
+# SPDX-FileCopyrightText: 2024 Mark Jonas <toe...@gmail.com>
+#
+# SPDX-License-Identifier: MIT
+
+FROM ubuntu:24.04
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+# Dummy uid/gid for devuser; will be changed at devcontainer startup
+ARG USER_UID=1234
+ARG USER_GID=1234
+ARG USER_SHELL=/bin/bash
+ARG USERNAME=devuser
+
+# Remove ubuntu user to free up uid:gid 1000:1000
+RUN userdel -r ubuntu || true
+
+RUN groupadd --gid ${USER_GID} ${USERNAME} && \
+ useradd --shell ${USER_SHELL} --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME}
+
+RUN apt-get update
+
+# Allow devuser to execute any command as root without password prompt
+RUN apt-get -y install --no-install-recommends sudo && \
+ echo "${USERNAME} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} && \
+ chmod 0440 /etc/sudoers.d/${USERNAME}
+
+# Install SWUpdate build dependencies
+COPY ./ci/setup.sh /tmp
+RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
+
+USER ${USERNAME}
+WORKDIR /home/${USERNAME}
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 00000000..9935f7e2
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,13 @@
+// SPDX-FileCopyrightText: 2024 Mark Jonas <toe...@gmail.com>
+//
+// SPDX-License-Identifier: MIT
+
+{
+ "name": "SWUpdate Development Container",
+ "build": {
+ "dockerfile": "Dockerfile",
+ "context": ".."
+ },
+ "remoteUser": "devuser",
+ "updateRemoteUserUID": true
+}
diff --git a/.gitignore b/.gitignore
index 4755ff07..24e9a38e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -127,6 +127,9 @@ web-app/swupdate-www.tar.gz
!.gitlab-ci.yml
!.github

+# devcontainer
+!.devcontainer/
+
# swupdateclient
Pipfile
Pipfile.lock
diff --git a/DevContainer.md b/DevContainer.md
new file mode 100644
index 00000000..c8c81e7a
--- /dev/null
+++ b/DevContainer.md
@@ -0,0 +1,26 @@
+<!--
+SPDX-FileCopyrightText: 2024 Mark Jonas <toe...@gmail.com>
+
+SPDX-License-Identifier: MIT
+-->
+
+# Introduction
+The SWUpdate devcontainer is a Docker-based development environment that
+ensures consistent tooling and settings across different machines. It uses
+configuration files to specify the environment setup and automatically builds
+the required development workspace when opened in compatible IDEs like VS Code.
+
+The devcontainer supports compiling and running SWUpdate for x86-64 targets.
+
+# Usage
+## Compile and run tests
+You can compile and run all SWUpdate tests inside the devcontainer. This is very
+helpful during development and highly recommend before sending a patch to the
+mailing list.
+
+To compile and run all SWUpdate tests, execute the following command using a
+devcontainer terminal.
+
+```
+ci/test-configs.sh
+```
--
2.43.0

Daniel Braunwarth

unread,
Dec 26, 2024, 1:16:10 AM12/26/24
to toe...@gmail.com, swup...@googlegroups.com
Hi Mark
Maybe we can think about using Podman instead of Docker. Non-root user
usage is such a pain with Docker.

I'm maintaining my own devcontainer on this branch:
https://github.com/d4nuu8/swupdate/tree/container

The following commit added the container image which is quite simple:
https://github.com/d4nuu8/swupdate/commit/47e8e54451a7f5d352cad288729330759ae8a13a

To use Podman us container engine with VS Code one only needs to change
the following setting:

"dev.containers.dockerPath": "podman"


This would eliminate all the user handling in the container and in the
devcontainer settings.

Just to be complete - the VS Code devcontainer configuration can be
found here:
https://github.com/d4nuu8/swupdate/commit/653fa66425cee6c5cc5e52a650cdfa233f47a77f



Regards

Daniel

Mark Jonas

unread,
Dec 26, 2024, 1:22:05 PM12/26/24
to o...@braunwarth.dev, swup...@googlegroups.com
Hi Daniel,

Thank you for your suggestions.

> Maybe we can think about using Podman instead of Docker. Non-root user
> usage is such a pain with Docker.

One benefit of the devcontainer is that Windows users can compile and
run SWUpdate as well. Is that also given when using Podman instead of
Docker? I found installation instructions for Podman on Windows / WSL2
but I do not know whether it works as well as Docker.

> I'm maintaining my own devcontainer on this branch:
> https://github.com/d4nuu8/swupdate/tree/container
>
> The following commit added the container image which is quite simple:
> https://github.com/d4nuu8/swupdate/commit/47e8e54451a7f5d352cad288729330759ae8a13a
>
> To use Podman us container engine with VS Code one only needs to change
> the following setting:
>
> "dev.containers.dockerPath": "podman"

I didn't get it working by adding the setting to the workspace'
.vscode/settings.json file. Is it possible that this can only be set
in the user settings? There, I was able to switch to Podman.

That could be a downside because this forces the developers to use
Podman for all their devcontainers. Besides that we could not offer an
out-of-the-box-experience because manual tweaking of the VS Code user
settings is required. And wouldn't then there possibly be other
devcontainers which do not work anymore?

>
>
> This would eliminate all the user handling in the container and in the
> devcontainer settings.

I am not sure I correctly understand the connection between Podman
running rootless and what I could skip in the container and the
settings.

The debian:testing-slim image does not have a regular user, just root.
But because Podman runs rootless it runs as the host user which runs
VS Code (which runs Podman) and thus root inside the container
effectively reads/writes with the uid and gid of the host user. And
that's why we could skip adding a devuser and adjusting uid and gid.
Right?

My experiments show that all files which are externally owned by my
user (1000:1000) are internally owned by root (0:0) with Podman.

> Just to be complete - the VS Code devcontainer configuration can be
> found here:
> https://github.com/d4nuu8/swupdate/commit/653fa66425cee6c5cc5e52a650cdfa233f47a77f

I got it working with Podman and the Dockerfile and devcontainer.json
do not need any of the user handling any more. IMHO it would be great
if the dev.containers.dockerPath could be set in the workspace
settings. But as a user settings it does not feel right for me.

Cheers,
Mark

Daniel Braunwarth

unread,
Dec 29, 2024, 4:58:11 AM12/29/24
to Mark Jonas, swup...@googlegroups.com
Hi Mark

On 26.12.24 19:21, Mark Jonas wrote:
> Hi Daniel,
>
> Thank you for your suggestions.
>
>> Maybe we can think about using Podman instead of Docker. Non-root user
>> usage is such a pain with Docker.
>
> One benefit of the devcontainer is that Windows users can compile and
> run SWUpdate as well. Is that also given when using Podman instead of
> Docker? I found installation instructions for Podman on Windows / WSL2
> but I do not know whether it works as well as Docker.

It should be doable for every developer to setup a WSL2 distro and
install Podman inside of it. The VS Code devcontainer can handle this
without any problem. You are able to start VS Code directly connected to
the container running in the WSL from Windows.

There is a Podman Desktop application available which is actually doing
the same thing:

https://podman-desktop.io/docs/installation/windows-install

If you want to enable "everybody" to develop SWUpdate by using Docker
for Windows this would be limited the following group as stated by the
license agreement of Docker for Windows:

Docker Desktop is free for small businesses (fewer than 250 employees
AND less than $10 million in annual revenue), personal use, education,
and non-commercial open source projects.

See https://docs.docker.com/subscription/desktop-license/


From my point of view Docker is a dead horse and I wouldn't spend any
time introducing it anywhere.
>
>> I'm maintaining my own devcontainer on this branch:
>> https://github.com/d4nuu8/swupdate/tree/container
>>
>> The following commit added the container image which is quite simple:
>> https://github.com/d4nuu8/swupdate/commit/47e8e54451a7f5d352cad288729330759ae8a13a
>>
>> To use Podman us container engine with VS Code one only needs to change
>> the following setting:
>>
>> "dev.containers.dockerPath": "podman"
>
> I didn't get it working by adding the setting to the workspace'
> .vscode/settings.json file. Is it possible that this can only be set
> in the user settings? There, I was able to switch to Podman.

That's indeed a problem. Right now it can only be set as a user settings.

I've requested this to be changed but Microsoft only added it the their
backlog so far:

https://github.com/microsoft/vscode-remote-release/issues/8817

> That could be a downside because this forces the developers to use
> Podman for all their devcontainers. Besides that we could not offer an
> out-of-the-box-experience because manual tweaking of the VS Code user
> settings is required. And wouldn't then there possibly be other
> devcontainers which do not work anymore?

I don't think we can ensure everything we are doing here is working for
everybody without any change to ones personal setup.

Adding documentation for developers how this devcontainer must be used
and who VS Code must be configured should be sufficient from my point of
view.

>> This would eliminate all the user handling in the container and in the
>> devcontainer settings.
>
> I am not sure I correctly understand the connection between Podman
> running rootless and what I could skip in the container and the
> settings.
>
> The debian:testing-slim image does not have a regular user, just root.
> But because Podman runs rootless it runs as the host user which runs
> VS Code (which runs Podman) and thus root inside the container
> effectively reads/writes with the uid and gid of the host user. And
> that's why we could skip adding a devuser and adjusting uid and gid.
> Right?

Right.

> My experiments show that all files which are externally owned by my
> user (1000:1000) are internally owned by root (0:0) with Podman.
>
>> Just to be complete - the VS Code devcontainer configuration can be
>> found here:
>> https://github.com/d4nuu8/swupdate/commit/653fa66425cee6c5cc5e52a650cdfa233f47a77f
>
> I got it working with Podman and the Dockerfile and devcontainer.json
> do not need any of the user handling any more. IMHO it would be great
> if the dev.containers.dockerPath could be set in the workspace
> settings. But as a user settings it does not feel right for me.
>
> Cheers,
> Mark

Regards
Daniel

Mark Jonas

unread,
Dec 30, 2024, 11:54:24 AM12/30/24
to Daniel Braunwarth, swup...@googlegroups.com, Stefano Babic, ayoub...@googlemail.com
Hi Daniel,

[..]

> It should be doable for every developer to setup a WSL2 distro and
> install Podman inside of it. The VS Code devcontainer can handle this
> without any problem. You are able to start VS Code directly connected to
> the container running in the WSL from Windows.
>
> There is a Podman Desktop application available which is actually doing
> the same thing:
>
> https://podman-desktop.io/docs/installation/windows-install
>
> If you want to enable "everybody" to develop SWUpdate by using Docker
> for Windows this would be limited the following group as stated by the
> license agreement of Docker for Windows:
>
> Docker Desktop is free for small businesses (fewer than 250 employees
> AND less than $10 million in annual revenue), personal use, education,
> and non-commercial open source projects.
>
> See https://docs.docker.com/subscription/desktop-license/

The licensing is a very good argument pro Podman.

> From my point of view Docker is a dead horse and I wouldn't spend any
> time introducing it anywhere.

[..]

> >> To use Podman us container engine with VS Code one only needs to change
> >> the following setting:
> >>
> >> "dev.containers.dockerPath": "podman"
> >
> > I didn't get it working by adding the setting to the workspace'
> > .vscode/settings.json file. Is it possible that this can only be set
> > in the user settings? There, I was able to switch to Podman.
>
> That's indeed a problem. Right now it can only be set as a user settings.
>
> I've requested this to be changed but Microsoft only added it the their
> backlog so far:
>
> https://github.com/microsoft/vscode-remote-release/issues/8817

Thanks for making Microsoft aware of this over a year ago. I keep my
fingers crossed that it soon bubbles up in their backlog.

> > That could be a downside because this forces the developers to use
> > Podman for all their devcontainers. Besides that we could not offer an
> > out-of-the-box-experience because manual tweaking of the VS Code user
> > settings is required. And wouldn't then there possibly be other
> > devcontainers which do not work anymore?
>
> I don't think we can ensure everything we are doing here is working for
> everybody without any change to ones personal setup.

It would be interesting to hear what Stefano and Ayoub think about it.

I think the manual change of the user settings would be acceptable. I
am optimistic that eventually the dev.containers.dockerPath setting
could be a workspace setting. I am not aware of a technical reason
against it.

> Adding documentation for developers how this devcontainer must be used
> and who VS Code must be configured should be sufficient from my point of
> view.

[..]

Cheers,
Mark

Stefano Babic

unread,
Jan 3, 2025, 4:19:18 AMJan 3
to Mark Jonas, Daniel Braunwarth, swup...@googlegroups.com, Stefano Babic, ayoub...@googlemail.com
Hi Mark, Daniel,
It seems MS does not take very seriously.

>
>>> That could be a downside because this forces the developers to use
>>> Podman for all their devcontainers. Besides that we could not offer an
>>> out-of-the-box-experience because manual tweaking of the VS Code user
>>> settings is required. And wouldn't then there possibly be other
>>> devcontainers which do not work anymore?
>>
>> I don't think we can ensure everything we are doing here is working for
>> everybody without any change to ones personal setup.

Agree, we cannot ensure that it works out of the box in any conditions.
However, we can add documentation to explain what should be done and how
to use it.

>
> It would be interesting to hear what Stefano and Ayoub think about it.
>
> I think the manual change of the user settings would be acceptable. I
> am optimistic that eventually the dev.containers.dockerPath setting
> could be a workspace setting. I am not aware of a technical reason
> against it.

Probably not a technical reason...

Sources are published, but there is no community and there is not a
single commit done by someone else but Microsoft.

>
>> Adding documentation for developers how this devcontainer must be used
>> and who VS Code must be configured should be sufficient from my point of
>> view.

I agree.

Best regards,
Stefano

toe...@gmail.com

unread,
Jan 3, 2025, 12:16:50 PMJan 3
to swup...@googlegroups.com, o...@braunwarth.dev, ayoub...@googlemail.com, stefan...@swupdate.org, ungerer...@gmail.com, Mark Jonas, Ayoub Zaki
From: Mark Jonas <toe...@gmail.com>

The devcontainer can build and run all SWUpdate tests for x86-64
targets. It uses ci/setup.sh to install the required build dependencies.

The devcontainer must be run unpriviledged. Thus, the root user inside
will read and write outside files with the uid and gid of the user who
started the container. This cannot be done using Docker but requires
Podman. Because of this the default container service of VS Code must be
switched from Docker to Podman.

Suggested-by: Ayoub Zaki <ayoub...@embetrix.com>
Suggested-by: Daniel Braunwarth <o...@braunwarth.dev>
Signed-off-by: Mark Jonas <toe...@gmail.com>
---
.devcontainer/Dockerfile | 11 +++++++
.devcontainer/devcontainer.json | 11 +++++++
.gitignore | 3 ++
DevContainer.md | 58 +++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+)
create mode 100644 .devcontainer/Dockerfile
create mode 100644 .devcontainer/devcontainer.json
create mode 100644 DevContainer.md

diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 00000000..0347971b
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,11 @@
+# SPDX-FileCopyrightText: 2024-2025 Mark Jonas <toe...@gmail.com>
+#
+# SPDX-License-Identifier: MIT
+
+FROM ubuntu:24.04
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+# Install SWUpdate build dependencies
+COPY ./ci/setup.sh /tmp
+RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 00000000..6fd7436a
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2024-2025 Mark Jonas <toe...@gmail.com>
+//
+// SPDX-License-Identifier: MIT
+
+{
+ "name": "SWUpdate Development Container",
+ "build": {
+ "dockerfile": "Dockerfile",
+ "context": ".."
+ }
+}
diff --git a/.gitignore b/.gitignore
index 4755ff07..24e9a38e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -127,6 +127,9 @@ web-app/swupdate-www.tar.gz
!.gitlab-ci.yml
!.github

+# devcontainer
+!.devcontainer/
+
# swupdateclient
Pipfile
Pipfile.lock
diff --git a/DevContainer.md b/DevContainer.md
new file mode 100644
index 00000000..56a864e7
--- /dev/null
+++ b/DevContainer.md
@@ -0,0 +1,58 @@
+<!--
+SPDX-FileCopyrightText: 2024-2025 Mark Jonas <toe...@gmail.com>
+
+SPDX-License-Identifier: MIT
+-->
+
+# Introduction
+
+The SWUpdate devcontainer is a Podman-based development environment that
+ensures consistent tooling and settings across different machines. It uses
+configuration files to specify the environment setup and automatically builds
+the required development workspace when opened in compatible IDEs like VS Code.
+
+The devcontainer requires Podman because it expects to be run unprivileged.
+That is, the root user inside the container is expected to read and write
+files with the uid and gid of the user who started the container.
+
+The devcontainer supports compiling and running SWUpdate for x86-64 targets.
+
+# Setup
+
+## VS Code
+
+You have to use *Podman* instead of *Docker* by adding the following to the
+VS Code user settings. Please note that changing this setting might break other
+devcontainers you are using which explicitly require Docker. [^1]
+
+[^1]: It is an open backlog item of VS Code to change *dev.containers.dockerPath*
+into a workspace setting. See https://github.com/microsoft/vscode-remote-release/issues/8817
+
+```
+"dev.containers.dockerPath": "podman"
+```
+
+You can change that setting either in VS Code itself (hotkey *Ctrl-,*) or in
+the configuration file. VS Code user settings are stored in a *settings.json*
+file, with different locations depending on your operating system:
+
+**Linux**: `$HOME/.config/Code/User/settings.json`
+
+**macOS**: `$HOME/Library/Application Support/Code/User/settings.json`
+
+**Windows**: `%APPDATA%\Code\User\settings.json`
+
+# Usage
+

Daniel Braunwarth

unread,
Jan 4, 2025, 9:14:16 AMJan 4
to toe...@gmail.com, swup...@googlegroups.com
Hi Mark
Podman is able to build a Dockerfile but the name Containerfile is
preferred in the podman context.

See
https://docs.podman.io/en/latest/markdown/podman-build.1.html#description

> diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
> new file mode 100644
> index 00000000..6fd7436a
> --- /dev/null
> +++ b/.devcontainer/devcontainer.json
> @@ -0,0 +1,11 @@
> +// SPDX-FileCopyrightText: 2024-2025 Mark Jonas <toe...@gmail.com>
> +//
> +// SPDX-License-Identifier: MIT
> +
> +{
> + "name": "SWUpdate Development Container",
> + "build": {
> + "dockerfile": "Dockerfile",
> + "context": ".."
> + }
> +}

At least "EditorConfig.EditorConfig" as VS Code extensions would be nice
from my point of view.

Adding port 8080 as forwarded port would probably make sense to be able
to debug any mongoose problems.
What do you want to achieve with this [^1]? At least the VS Code
Markdown renderer is not able to do anything with this.


> +
> +[^1]: It is an open backlog item of VS Code to change *dev.containers.dockerPath*
> +into a workspace setting. See https://github.com/microsoft/vscode-remote-release/issues/8817

Create a real link:
See <https://github.com/microsoft/vscode-remote-release/issues/8817>.

> +
> +```
> +"dev.containers.dockerPath": "podman"
> +```

Add language to code block:

```json
dev.containers.dockerPath": "podman"
Add language to code block:

```sh
ci/test-configs.sh
```


Regards
Daniel

Mark Jonas

unread,
Jan 5, 2025, 8:09:56 AMJan 5
to Daniel Braunwarth, swup...@googlegroups.com
Hi Daniel,

[..]

> > diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
> > new file mode 100644
> > index 00000000..0347971b
> > --- /dev/null
> > +++ b/.devcontainer/Dockerfile
> > @@ -0,0 +1,11 @@
> > +# SPDX-FileCopyrightText: 2024-2025 Mark Jonas <toe...@gmail.com>
> > +#
> > +# SPDX-License-Identifier: MIT
> > +
> > +FROM ubuntu:24.04
> > +
> > +ARG DEBIAN_FRONTEND=noninteractive
> > +
> > +# Install SWUpdate build dependencies
> > +COPY ./ci/setup.sh /tmp
> > +RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
>
> Podman is able to build a Dockerfile but the name Containerfile is
> preferred in the podman context.
>
> See
> https://docs.podman.io/en/latest/markdown/podman-build.1.html#description

OK. Renamed Dockerfile to Containerfile.

> > diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
> > new file mode 100644
> > index 00000000..6fd7436a
> > --- /dev/null
> > +++ b/.devcontainer/devcontainer.json
> > @@ -0,0 +1,11 @@
> > +// SPDX-FileCopyrightText: 2024-2025 Mark Jonas <toe...@gmail.com>
> > +//
> > +// SPDX-License-Identifier: MIT
> > +
> > +{
> > + "name": "SWUpdate Development Container",
> > + "build": {
> > + "dockerfile": "Dockerfile",
> > + "context": ".."
> > + }
> > +}
>
> At least "EditorConfig.EditorConfig" as VS Code extensions would be nice
> from my point of view.

I think that is a good idea for a follow up contribution. I think we
should focus on one feature at a time. That will make it easier for
review and alignment. And we can make sure that the documentation is
still a perfect fit.

> Adding port 8080 as forwarded port would probably make sense to be able
> to debug any mongoose problems.

Same here. IMHO definitely a good idea and can be contributed in a
dedicated followup feature. A paragraph in the documentation
describing the feature similar to the one on how to run the tests
would be great.

[..]
[^1]: is the notation for a footnote as supported by the markdown
renderers of GitHub and GitLab.

https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#footnotes
https://docs.gitlab.com/ee/user/markdown.html#footnotes

As SWUpdate is hosted on GitHub and its CI/CD it runs on the Denx
GitLab instance, I think it is OK.

What I wanted to achieve is to document that eventually the setting
might become a workspace setting. But that information should not
interrupt the flow of reading.

Do you think it is important that the markdown is perfectly rendered
within VS Code? If yes, how would you substitute the footnote?

> > +
> > +[^1]: It is an open backlog item of VS Code to change *dev.containers.dockerPath*
> > +into a workspace setting. See https://github.com/microsoft/vscode-remote-release/issues/8817
>
> Create a real link:
> See <https://github.com/microsoft/vscode-remote-release/issues/8817>.

I skimmed the MD documentation of GitHub and GitLab and did not find
the <..> notation for links. Both support [..](..) for links with link
text and URL auto-linking for raw links.

In my understanding <..> is reserved for inline HTML tags.

> > +
> > +```
> > +"dev.containers.dockerPath": "podman"
> > +```
>
> Add language to code block:
>
> ```json
> dev.containers.dockerPath": "podman"
> ```

OK. done. Adds a little bit of color.

> > +
> > +You can change that setting either in VS Code itself (hotkey *Ctrl-,*) or in

I changed the formatting of the hotkey to a code block. This looks
similar to how it is done in the official VS Code documentation.
OK, done. This did not change anything in the rendered view.

I'll wait a little for further feedback and then send a v3 of the
patch. You can find a preview of the changes I did at
https://gitlab.com/toertel-contribute/swupdate/swupdate/-/tree/feature/devcontainer/
.

Cheers,
Mark

toe...@gmail.com

unread,
Jan 6, 2025, 12:00:54 PMJan 6
to swup...@googlegroups.com, o...@braunwarth.dev, ayoub...@googlemail.com, stefan...@swupdate.org, ungerer...@gmail.com, Mark Jonas
From: Mark Jonas <toe...@gmail.com>

Changes for v2:
- Use Podman instead of Docker
- Simplify container by using unprivileged root user

Changes for v3:
- Rename Dockerfile to Containerfile
- Add syntax highlighting to code blocks in markdown
- Use code block formatting for hotkeys similar like it is done in
VS Code documentation

Mark Jonas (1):
Add minimal devcontainer

.devcontainer/Containerfile | 11 +++++++
.devcontainer/devcontainer.json | 11 +++++++
.gitignore | 3 ++
DevContainer.md | 58 +++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+)
create mode 100644 .devcontainer/Containerfile
create mode 100644 .devcontainer/devcontainer.json
create mode 100644 DevContainer.md

--
2.43.0

toe...@gmail.com

unread,
Jan 6, 2025, 12:01:05 PMJan 6
to swup...@googlegroups.com, o...@braunwarth.dev, ayoub...@googlemail.com, stefan...@swupdate.org, ungerer...@gmail.com, Mark Jonas, Ayoub Zaki
From: Mark Jonas <toe...@gmail.com>

The devcontainer can build and run all SWUpdate tests for x86-64
targets. It uses ci/setup.sh to install the required build dependencies.

The devcontainer must be run unprivileged. Thus, the root user inside
will read and write outside files with the uid and gid of the user who
started the container. This cannot be done using Docker but requires
Podman. Because of this the default container service of VS Code must be
switched from Docker to Podman.

Suggested-by: Ayoub Zaki <ayoub...@embetrix.com>
Suggested-by: Daniel Braunwarth <o...@braunwarth.dev>
Signed-off-by: Mark Jonas <toe...@gmail.com>
---
.devcontainer/Containerfile | 11 +++++++
.devcontainer/devcontainer.json | 11 +++++++
.gitignore | 3 ++
DevContainer.md | 58 +++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+)
create mode 100644 .devcontainer/Containerfile
create mode 100644 .devcontainer/devcontainer.json
create mode 100644 DevContainer.md

diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile
new file mode 100644
index 00000000..0347971b
--- /dev/null
+++ b/.devcontainer/Containerfile
@@ -0,0 +1,11 @@
+# SPDX-FileCopyrightText: 2024-2025 Mark Jonas <toe...@gmail.com>
+#
+# SPDX-License-Identifier: MIT
+
+FROM ubuntu:24.04
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+# Install SWUpdate build dependencies
+COPY ./ci/setup.sh /tmp
+RUN chmod +x /tmp/setup.sh && /tmp/setup.sh
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 00000000..082e304c
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: 2024-2025 Mark Jonas <toe...@gmail.com>
+//
+// SPDX-License-Identifier: MIT
+
+{
+ "name": "SWUpdate Development Container",
+ "build": {
+ "dockerfile": "Containerfile",
+ "context": ".."
+ }
+}
diff --git a/.gitignore b/.gitignore
index 4755ff07..24e9a38e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -127,6 +127,9 @@ web-app/swupdate-www.tar.gz
!.gitlab-ci.yml
!.github

+# devcontainer
+!.devcontainer/
+
# swupdateclient
Pipfile
Pipfile.lock
diff --git a/DevContainer.md b/DevContainer.md
new file mode 100644
index 00000000..dac6a26d
--- /dev/null
+
+[^1]: It is an open backlog item of VS Code to change *dev.containers.dockerPath*
+into a workspace setting. See https://github.com/microsoft/vscode-remote-release/issues/8817
+
+```json
+"dev.containers.dockerPath": "podman"
+```
+
+You can change that setting either in VS Code itself (press `Ctrl+,`) or in
+the configuration file. VS Code user settings are stored in a *settings.json*
+file, with different locations depending on your operating system:
+
+**Linux**: `$HOME/.config/Code/User/settings.json`
+
+**macOS**: `$HOME/Library/Application Support/Code/User/settings.json`
+
+**Windows**: `%APPDATA%\Code\User\settings.json`
+
+# Usage
+
+## Compile and run tests
+
+You can compile and run all SWUpdate tests inside the devcontainer. This is very
+helpful during development and highly recommended before sending a patch to the
+mailing list.
+
+To compile and run all SWUpdate tests, execute the following command using a
+devcontainer terminal.
+
+```sh
+ci/test-configs.sh
+```
--
2.43.0

Reply all
Reply to author
Forward
0 new messages