diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..203f4ed4c --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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 \ + 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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..e0cc3ea6a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +{ + "name": "Netplan Development", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "remoteUser": "ubuntu" +} diff --git a/HACKING.md b/HACKING.md new file mode 100644 index 000000000..88f315b3f --- /dev/null +++ b/HACKING.md @@ -0,0 +1,16 @@ +# Hacking Guide + +## Container Usage + +### VS Code Dev Container + +A devcontainer is provided under `.devcontainer/`. + +1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). +2. Open this repository in VS Code. +3. Run `Dev Containers: Reopen in Container` from the Command Palette. + +## Notes + +- The Docker image is useful for reproducible builds and many tests. +- Some system-level integration scenarios (for example, full network service lifecycle behavior) are better exercised VM-based environments. diff --git a/README.md b/README.md index b5494f201..19315245a 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,11 @@ 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/). +For development workflows (including VS Code container usage), see [HACKING.md](HACKING.md). + # Build dependencies -Install the required build and test dependencies (Ubuntu/Debian): +For a manual setup without containers, install the required build and test dependencies: ```sh sudo apt install \ @@ -98,7 +100,7 @@ Convenience targets are available via `make`: - `make run ARGS=''` Run the locally built netplan CLI with the appropriate environment, for example, to run `netplan help`: ```sh - $ make run ARGS="help" + make run ARGS="help" ``` # Test local build @@ -106,14 +108,14 @@ Convenience targets are available via `make`: After running: ```sh -$ make -$ make install +make +make install ``` the locally built `netplan` can be tested without installing it system-wide: ```sh -$ make run ARGS="" +make run ARGS="" ``` This wrapper sets the required environment variables (such as `NETPLAN_GENERATE_PATH`) automatically. These are needed because the Python CLI resolves binary and library paths at runtime. @@ -121,7 +123,7 @@ This wrapper sets the required environment variables (such as `NETPLAN_GENERATE_ As an example, let's use `make run` to run `netplan info`: ```sh -$ make run ARGS="info" +make run ARGS="info" # output: netplan.io: website: "https://netplan.io/"