adapted from this

notes

  • MartyPC local build (checks out repository at specific commit)
  • targets X11, Mesa EGL, GTK3
FROM debian:12.11
 
ARG U_NAME="user"
ARG U_ID="1000"
RUN adduser --disabled-password --gecos '' --uid ${U_ID} ${U_NAME}
 
 
WORKDIR /home/${U_NAME}
 
#=================================#
# install Rust
 
USER root
RUN apt-get update && apt-get install -y \
		curl \
	&& rm -rf /var/lib/apt/lists/*
 
USER ${U_NAME}
RUN \
	curl --proto '=https' --tlsv1.2 -sSf -o ./rustup-init.sh https://sh.rustup.rs && \
	sh ./rustup-init.sh -y
#=================================#
 
#=================================#
# download + build MartyPC
 
USER root
 
# as indicated by docs
RUN apt-get update && apt-get install -y \
		git \
		curl \
		build-essential \
		pkg-config \
		libasound2-dev \
		libudev-dev \
		libc-dev \
		libx11-dev \
		libclang-dev \
	&& rm -rf /var/lib/apt/lists/*
 
# for X11
RUN apt-get update && apt-get install -y \
		libxcursor1 \
		libx11-xcb1 \
		libxi6 \
		libxkbcommon-x11-dev \
	&& rm -rf /var/lib/apt/lists/*
 
# for GL backend
RUN apt-get update && apt-get install -y \
		libegl1-mesa-dev \
	&& rm -rf /var/lib/apt/lists/*
 
# NOTE: pair with the following in Cargo.toml: `rfd = { version = "0.15", default-features = false, features = ["gtk3"] }`
# - otherwise tries to use "xdg-portal", requires extra config/setup to make that work properly
RUN apt-get update && apt-get install -y \
		libgtk-3-dev \
	&& rm -rf /var/lib/apt/lists/*
 
 
USER ${U_NAME}
 
# switch to "nightly" channel
RUN \
	/home/${U_NAME}/.cargo/bin/rustup install nightly && \
	/home/${U_NAME}/.cargo/bin/rustup default nightly
RUN git clone https://github.com/dbalsom/martypc.git
RUN \
	cd ./martypc && \
	git checkout bc5b03e5b9fd1aa7f8374a60d70b0b5f1002a9a2 && \
	cd ./install && \
	/home/${U_NAME}/.cargo/bin/cargo build --release
#=================================#
 
#=================================#
USER root
 
# for GUI stuff (via host)
RUN usermod -a -G audio ${U_NAME}
RUN usermod -a -G video ${U_NAME}
RUN groupadd -g 106 render && usermod -a -G render ${U_NAME}
#=================================#
 
USER ${U_NAME}

if you want to persist the build cache between container runs, you can add something like this to your container run invocation:

-v /path/to/hostmounted_dir:/home/user/hostmounted_cargohome
-e CARGO_HOME=/home/user/hostmounted_cargohome

for passing audio/video from host: