ref: 9546b2f0392a606bb6220671741525ba40480685
parent: 41865b179684eaf812fc9682936d9b79320f5a1d
parent: b780b11e7daad47872cadc97a101501c9d9d165f
author: Simon Howard <[email protected]>
date: Fri Feb 11 22:11:32 EST 2022
Merge pull request #1442 from fsufitch/vscode_dev_container Support for Docker container-based development for ease and consistency
--- /dev/null
+++ b/.devcontainer/.gitignore
@@ -1,0 +1,4 @@
+*.xauth
+wads/
+prefs/
+share/
\ No newline at end of file
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -1,0 +1,39 @@
+FROM ubuntu
+
+######### Apt dependencies
+
+ARG system_apt_dependencies="build-essential gdb automake autoconf libtool git pkg-config python3 python3-pip sudo"
+ARG choco_apt_dependencies="gcc make libsdl2-dev libsdl2-net-dev libsdl2-mixer-dev"
+ARG choco_apt_dependencies_optional="libflac-dev libpng-dev libsamplerate-dev libvorbis-dev"
+RUN apt-get update && \
+ DEBIAN_FRONTEND=noninteractive apt-get install -qq $system_apt_dependencies $choco_apt_dependencies $choco_apt_dependencies_optional
+
+########## Install Pillow (PIL) via pip, not apt
+
+ARG choco_pip_dependencies="pillow"
+RUN pip install $choco_pip_dependencies
+
+########## Container user setup
+
+ARG USERNAME=chocodev
+ARG USER_UID=1000
+ARG USER_GID=$USER_UID
+RUN groupadd --gid $USER_GID $USERNAME \
+ && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
+
+# Add sudo support
+RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
+ && chmod 0440 /etc/sudoers.d/$USERNAME
+
+# Add the user to the audio group, to have ALSA sound access
+# TODO: pulseaudio, so this isn't necessary?
+RUN addgroup $USERNAME audio
+
+# Use bash, not sh. Yuck.
+RUN chsh $USERNAME -s /bin/bash
+
+USER $USERNAME
+
+# Make sure we actually own our own local share stuff
+RUN mkdir -p /home/$USERNAME/.local/share && \
+ chown -R $USERNAME:$USERNAME /home/$USERNAME/.local
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -1,0 +1,45 @@
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
+// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/docker-existing-dockerfile
+{
+ "name": "Doom Dev Container",
+ "context": "..",
+ "dockerFile": "./Dockerfile",
+
+ "extensions": [
+ "yzhang.markdown-all-in-one",
+ "bierner.markdown-preview-github-styles",
+ "dotjoshjohnson.xml",
+
+ "eamodio.gitlens",
+ "npxms.hide-gitignored", // Note: need to run its command manually
+
+ // Build tooling
+ "ms-vscode.cpptools",
+ "cschlosser.doxdocgen",
+ "austin.code-gnu-global",
+ "jeff-hykin.better-cpp-syntax", // Note: runs locally
+ "ms-vscode.cpptools-themes", // Note: runs locally
+ ],
+
+ // Required to not bleed "root" permission files into the host volume
+ "containerUser": "chocodev",
+
+ // VSCode on Linux specific, for creating X11 and sound forwarding
+ // Comment out manually if working on non-Linux
+ "initializeCommand": "${localWorkspaceFolder}/.devcontainer/initialize-linux.sh",
+ "mounts": [
+ "source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind",
+ "source=${localWorkspaceFolder}/.devcontainer/prefs,target=/home/chocodev/.local/share/chocolate-doom,type=bind",
+ ],
+ "containerEnv": {
+ "DISPLAY": "${localEnv:DISPLAY}",
+ "XAUTHORITY": "${containerWorkspaceFolder}/.devcontainer/share/devcontainer.xauth",
+ },
+ "runArgs": [
+ // "--gpus", "all", // Uncomment for GPU support
+ "--device", "/dev/snd",
+ // TODO: pulseaudio? https://github.com/mviereck/x11docker/wiki/Container-sound:-ALSA-or-Pulseaudio
+ ]
+
+ // TODO: X11/sound forwarding configs for MacOS (XQuartz) and Windows (Xming)
+}
--- /dev/null
+++ b/.devcontainer/initialize-linux.sh
@@ -1,0 +1,9 @@
+#!/bin/bash
+HERE=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
+
+### Create the xauth file allowing the container to interact with a forwarded X11
+XAUTH="$HERE/share/devcontainer.xauth";
+touch "$XAUTH"
+xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
+
+### TODO: pulseaudio pasthrough
\ No newline at end of file
--- a/.gitignore
+++ b/.gitignore
@@ -57,3 +57,7 @@
GRTAGS
GTAGS
/HTML/
+
+# VSCode settings
+
+/.vscode/
\ No newline at end of file