Skip to content

Instantly share code, notes, and snippets.

@Arnavion
Created February 3, 2023 05:08
Show Gist options
  • Save Arnavion/81006757190c29aa0b24c674e241bf2a to your computer and use it in GitHub Desktop.
Save Arnavion/81006757190c29aa0b24c674e241bf2a to your computer and use it in GitHub Desktop.
steam in podman container
# ~/src/non-oss-container/build.sh
#!/bin/bash
set -euo pipefail
mkdir -p ~/non-oss-root/
podman image rm --force localhost/non-oss || :
podman image build \
--layers=false \
--tag=localhost/non-oss \
"--build-arg=uid=$(id -u)" \
"--build-arg=input_gid=$(getent group input | cut -d: -f 3)" \
~/src/non-oss-container/build
podman image rm docker.io/library/ubuntu:22.04
# ~/src/non-oss-container/build/Containerfile
FROM docker.io/library/ubuntu:22.04
ARG uid
ARG input_gid
COPY setup.sh /setup.sh
RUN ["/setup.sh"]
USER arnavion
ENV HOME /home/arnavion
ENV XDG_RUNTIME_DIR "/run/user/$uid"
# ~/src/non-oss-container/build/setup.sh
#!/bin/bash
set -euo pipefail
[ -n "$uid" ]
[ -n "$input_gid" ]
dpkg --add-architecture i386
export DEBIAN_FRONTEND=noninteractive
export TZ=America/Los_Angeles
apt-get update -y
apt-get upgrade -y
apt-get install -y --no-install-recommends \
steam \
ca-certificates curl \
libatomic1 libgbm1 libgl1 libnss3 libopenal1:i386 libxss1 locales \
mesa-vulkan-drivers mesa-vulkan-drivers:i386 \
pavucontrol \
unifont \
x11-apps \
x11-xserver-utils
# To run with STEAM_RUNTIME=0, also run:
#
# apt-get install -y \
# dbus:i386 libbz2-1.0:i386 libdbus-glib-1-2:i386 libgtk2.0-0:i386 libgudev-1.0-0:i386 libice6:i386 \
# libnm0:i386 libopenal1:i386 libpulse0:i386 libsm6:i386 libva-x11-2:i386 libvdpau1:i386 libxtst6:i386
useradd -u "$uid" arnavion
passwd -d arnavion
mkdir -p "/run/user/$uid"
chown arnavion:arnavion "/run/user/$uid"
groupadd -g "$input_gid" input
usermod -aG input arnavion
locale-gen en_US.UTF-8
update-locale LANG=en_US.UTF-8
apt-get clean
rm /setup.sh
# ~/src/non-oss-container/common.sh
mkdir -p ~/non-oss-root/"$NAME"/.config/pulse
PODMAN_ARGS=(
--device=/dev/dri
"--env=DISPLAY=$DISPLAY"
'--env=PULSE_SINK=alsa_output.pci-0000_0a_00.3.analog-stereo'
"--hostname=$HOSTNAME-non-oss"
"--name=$NAME"
--shm-size=1G
--userns=keep-id \
"--volume=$XDG_RUNTIME_DIR/pulse:/run/user/$(id -u)/pulse"
"--volume=/tmp/.X11-unix/X${DISPLAY#:}:/tmp/.X11-unix/X${DISPLAY#:}"
"--volume=$(realpath ~/non-oss-root/$NAME):$HOME"
localhost/non-oss
)
# ~/.local/bin/steam
#!/bin/bash
set -euo pipefail
COMMAND="${@:-/usr/games/steam -nofriendsui -nochatui -no-browser steam://open/minigameslist}"
NAME='steam'
. ~/src/non-oss-container/common.sh
exec podman container run \
--interactive --tty --rm \
--device=/dev/input \
"${PODMAN_ARGS[@]}" \
$COMMAND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment