From be97b1f0d7ab8040dd7e76eabe2cbc9a4fc2f920 Mon Sep 17 00:00:00 2001 From: "Antoine C." Date: Sat, 14 Dec 2024 03:09:57 +0000 Subject: [PATCH] feat: add devcontainer --- .devcontainer/Dockerfile | 34 ++++++++++++++++++++ .devcontainer/devcontainer.json | 55 +++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 1 + README.md | 23 ++++++++++++++ tools/debian_buildenv.sh | 2 ++ 5 files changed, 115 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..b426251a8a5 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,34 @@ +FROM ubuntu:24.04 + +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get update && \ + apt-get install -y \ + build-essential \ + git \ + gdb \ + sudo \ + python3-pip \ + pulseaudio-utils \ + pipewire-alsa \ + pipewire \ + alsa-utils \ + adwaita-qt \ + libadwaitaqt1 \ + udev \ + vim \ + clangd && \ + pip3 install pre-commit --break-system-packages + +COPY tools/debian_buildenv.sh /tmp/ + +RUN /tmp/debian_buildenv.sh setup + +RUN userdel -f -r ubuntu && \ + mkdir /home/developer && echo "developer ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/developer && \ + mkdir -p \ + /home/developer/.cache/pre-commit \ + /home/developer/.devcontainer \ + /home/developer/.mixxx \ + /tmp/ccache && \ + touch /home/developer/.devcontainer/.bash_history && \ + chown -R 1000:1000 /home/developer/ /tmp/ccache && \ + echo ". /etc/bash_completion\nexport PROMPT_COMMAND='history -a'\nexport HISTFILE='/home/developer/.devcontainer/.bash_history'" >> /home/developer/.bashrc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..cbb6ce7592d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,55 @@ +{ + "name": "mixxx", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "securityOpt": ["label=type:container_runtime_t"], + "runArgs": [ + // Uncomment the following to enable HID controller support in the container. Make sure to replace `/dev/hidraw7` with your device address + // "--device=/dev/bus/usb/003/049", + // "--device=/dev/hidraw7", + "--network=host" // This is needed for native X.org support + ], + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "false", + "username": "developer", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": "false" + } + }, + "initializeCommand": "touch ${localEnv:HOME}${localEnv:USERPROFILE}/.gitignore", + "customizations": { + "vscode": { + "extensions": ["llvm-vs-code-extensions.vscode-clangd", "eamodio.gitlens"] + } + }, + "remoteEnv": { + "DISPLAY": "${localEnv:DISPLAY::0}", + "XDG_SESSION_DESKTOP": "${localEnv:XDG_SESSION_DESKTOP:gnome}", + "XDG_SESSION_TYPE": "${localEnv:XDG_SESSION_TYPE:wayland}", + "XAUTHORITY": "${localEnv:XAUTHORITY}", + "WAYLAND_DISPLAY": "${localEnv:WAYLAND_DISPLAY:wayland-0}", + "XDG_SESSION_CLASS": "${localEnv:XDG_SESSION_CLASS:user}", + "XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR:/run/user/1000}", + "QT_QPA_PLATFORM": "${localEnv:QT_QPA_PLATFORM:wayland}" // Default to Wayland session, can also use 'xcb' to use X.org instead + }, + "remoteUser": "developer", + "postCreateCommand": "git config --global core.excludesFile '/home/developer/.gitignore' && git config --global --add safe.directory ${containerWorkspaceFolder} && pre-commit install --overwrite --install-hooks", + "mounts": [ + "type=bind,source=${localEnv:HOME},target=${localEnv:HOME},rslave", + "type=bind,source=${localEnv:XDG_RUNTIME_DIR},target=${localEnv:XDG_RUNTIME_DIR}", + "type=bind,source=/var/run/dbus/system_bus_socket,target=/var/run/dbus/system_bus_socket", + "type=bind,source=/dev/snd,target=/dev/snd", + "type=bind,source=/media,target=/media,rslave", + "type=bind,source=/mnt,target=/mnt,rslave", + "type=bind,source=/run/media,target=/run/media,rslave", + // Dev volumes used for persistence between containers + "type=volume,source=mixxx-bashistory,target=/home/developer/.devcontainer", + "type=volume,source=mixxx-precommit,target=/home/developer/.cache/pre-commit", + "type=volume,source=mixxx-config,target=/home/developer/.mixxx", + "type=volume,source=mixxx-ccache,target=/tmp/ccache" + ] +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1cb59d8f7da..bc70ca37659 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,6 +38,7 @@ repos: exclude: ^.*(\.cbproj|\.groupproj|\.props|\.sln|\.vcxproj|\.vcxproj.filters|UTF-8-BOM.txt)$ - id: check-case-conflict - id: check-json + exclude: ^(.devcontainer/devcontainer.json)$ # Contains JSON comment, which isn't supported by the hook - id: check-merge-conflict - id: check-xml - id: check-yaml diff --git a/README.md b/README.md index 09a41fb37a2..cdb797761cf 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,29 @@ To build Mixxx, run There should now be a `mixxx` executable in the current directory that you can run. Alternatively, can generate a package using `cpack`. +### Using Dev Container + +> [!NOTE] +> Dev container have recently been introduced and they are likely incomplete! It's been tested with `devpod` on Zed + +We provide a DevContainer definition for Mixxx. The container base uses Ubuntu 24.04. The decision is made to ensure a close environment with the build CI. +Similar to Fedora Toolbox's default, the default configuration provide a comprehensive definition of mounts which will allow use to use Mixxx seamlessly in the container. +If you are not comfortable with this, you may want to remove some or all of the binding before starting the container. + +You can build Mixxx using a similar command: + +```bash +mkdir build +cd build +cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON # Needed for clangd +cmake --build . -j $(nproc) +./mixxx +``` + +#### Using your device in DevContainer + +Audio card should be supported by default, thanks to the provided binds. You should be able to mount HID devices by updating the [`devcontainer.json` file](.devcontainer/devcontainer.json) + ## Documentation For help using Mixxx, there are a variety of options: diff --git a/tools/debian_buildenv.sh b/tools/debian_buildenv.sh index 95ef67967ec..ae740db58ee 100755 --- a/tools/debian_buildenv.sh +++ b/tools/debian_buildenv.sh @@ -59,6 +59,7 @@ case "$1" in g++ \ lcov \ libbenchmark-dev \ + libboost-dev \ libchromaprint-dev \ libdistro-info-perl \ libebur128-dev \ @@ -104,6 +105,7 @@ case "$1" in qt6-declarative-private-dev \ qt6-base-private-dev \ qt6-qpa-plugins \ + qt6-wayland \ qml6-module-qt5compat-graphicaleffects \ qml6-module-qtqml-workerscript \ qml6-module-qtquick-controls \