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/README.md b/README.md index b5494f201..2442f3863 100644 --- a/README.md +++ b/README.md @@ -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 ``` +# 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.