Skip to content

chore: add dev container support for simplicity#581

Open
Tony-WLB wants to merge 2 commits intocanonical:mainfrom
Tony-WLB:feat
Open

chore: add dev container support for simplicity#581
Tony-WLB wants to merge 2 commits intocanonical:mainfrom
Tony-WLB:feat

Conversation

@Tony-WLB
Copy link
Copy Markdown
Contributor

This pull request introduces a development container setup to streamline onboarding and development for the Netplan project. It also completes the dependencies list.

Dev container environment:

  • .devcontainer/Dockerfile - define a reproducible Ubuntu 24.04-based development environment
  • .devcontainer/devcontainer.json - configure the dev container

Documentation updates:

  • Updated the README.md to mention the new dev container as an alternative to manual dependency installation, and revised the dependency list to match the packages installed in the dev container.

Comment thread .devcontainer/Dockerfile Outdated

WORKDIR /workspace

USER netplan
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to use the default ubuntu user to avoid having to do useradd/usermod and stuff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user is changed to the default ubuntu.

Comment thread .devcontainer/Dockerfile Outdated
python3-pytest \
python3-pytest-cov \
python3-yaml \
sudo \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed? Isn't it installed by default in ubuntu?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I double-checked that the sudo package is not included by default in the Docker Ubuntu image.

Comment thread .devcontainer/Dockerfile
Comment thread README.md Outdated

```sh
sudo apt install \
bash-completion \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, we can link to the Dockerfile here for the list of deps, to avoid them getting out of sync.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. This part refers to the # netplan dependencies section in the Dockerfile now.

Comment thread README.md Outdated

# Build dependencies

> If you prefer using a prebuilt development environment, see the dev container image definition in [`.devcontainer/Dockerfile`](.devcontainer/Dockerfile).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a few commands for how you use Docker to start a container in your terminal. Something like this (completely untested):

docker build
docker run ./myfile
$ make
$ ./netplan foo  # or "make run"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build and run command examples have been added.

Comment thread README.md
gcovr \
pandoc
$ docker build -t netplan-dev -f .devcontainer/Dockerfile .
$ docker run -it --rm -v $(pwd):/workspace --name netplan-dev netplan-dev bash
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is helpful. However, I think to make this useful we have to be able to build netplan and run it, from within the container. But make in the container doesn't work:

ubuntu@c7be5a34e560:/workspace$ make
meson compile -C _build --verbose
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /workspace/_build -v
ninja: Entering directory `/workspace/_build'
ninja: error: '/home/ben.hoyt@canonical.com/w/netplan/features_h_generator.sh', needed by 'dbus/_features.h', missing and no known rule to make it
make: *** [Makefile:8: default] Error 1

Do you know why?

Comment thread README.md
gcovr \
pandoc
$ docker build -t netplan-dev -f .devcontainer/Dockerfile .
$ docker run -it --rm -v $(pwd):/workspace --name netplan-dev netplan-dev bash
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is helpful, and works on my machine. However, I think to make this useful we have to be able to build and run netplan from within the container. But make doesn't work for me:

ubuntu@c7be5a34e560:/workspace$ make
meson compile -C _build --verbose
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /workspace/_build -v
ninja: Entering directory `/workspace/_build'
ninja: error: '/home/ben.hoyt@canonical.com/w/netplan/features_h_generator.sh', needed by 'dbus/_features.h', missing and no known rule to make it
make: *** [Makefile:8: default] Error 1

Do you know why? I'm guessing it's an error with non-relative directories (the error references /home/ben.hoyt@canonical.com/w/netplan but I think that should be /workspace inside the container).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants