Skip to content

Commit

Permalink
feat: add devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Jan 18, 2025
1 parent 61178b6 commit cebc3a9
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tools/debian_buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ case "$1" in
g++ \
lcov \
libbenchmark-dev \
libboost-dev \
libchromaprint-dev \
libdistro-info-perl \
libebur128-dev \
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit cebc3a9

Please sign in to comment.