Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

# netplan dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
Comment thread
benhoyt marked this conversation as resolved.
bash-completion \
build-essential \
cmake \
gcovr \
libcmocka-dev \
libglib2.0-dev \
libsystemd-dev \
libyaml-dev \
meson \
network-manager \
pandoc \
pkg-config \
pycodestyle \
pyflakes3 \
python3-cffi \
python3-coverage \
python3-dev \
python3-pytest \
python3-pytest-cov \
python3-yaml \
systemd \
udev \
uuid-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# devcontainer dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
sudo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN echo "ubuntu ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ubuntu \
&& chmod 0440 /etc/sudoers.d/ubuntu

WORKDIR /workspace

USER ubuntu
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Netplan Development",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"remoteUser": "ubuntu"
}
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,29 @@ To contribute documentation, these steps should get you started:

If you face issues, refer to our [comprehensive contribution guide](https://netplan.readthedocs.io/en/stable/contribute-docs/).

# Build dependencies
# Development Container

A Docker-based development environment is available via `.devcontainer/` for consistent builds across machines.

## Using the Dev Container

### With VS Code

Install the required build and test dependencies (Ubuntu/Debian):
1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
2. Open the workspace in a container: Open the Command Palette and run "Dev Containers: Reopen in Container"
3. The container automatically installs all dependencies and configures the `ubuntu` user

### Manual Docker Build

```sh
sudo apt install \
build-essential \
pkg-config \
meson \
libglib2.0-dev \
libyaml-dev \
libsystemd-dev \
uuid-dev \
bash-completion \
python3-dev \
python3-cffi \
python3-coverage \
python3-pytest \
python3-pytest-cov \
pyflakes3 \
pycodestyle \
libcmocka-dev \
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?

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).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@benhoyt I did not run into this issue. I am running this container build from within an Ubuntu VM and is compiling fine.

As you had mentioned, it is likely due to difference in the directory referred during the build.

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.

Maybe it's caused by the volume not being mounted correctly, -v $(pwd):/workspace. It combines the CWD with the workspace inside the container. Could you please try running this Docker container directly inside the netplan directory?

```

# Build dependencies

For a manual setup without containers, install the required build and test dependencies. The full list of dependencies is defined in [`.devcontainer/Dockerfile`](.devcontainer/Dockerfile#L6) under the `# netplan dependencies` section.

# Build using Meson

A Makefile wrapper is also provided for simplified usage. For that approach, please refer to the [Build using Makefile](#build-using-makefile) section below.
Expand Down
Loading