diff --git a/Dockerfile b/Dockerfile index 92d9c16..8ed06f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,30 +4,35 @@ COPY ./aur-packages/srcpkgs/cage-vi/ /tmp/cage/ RUN pacman -Syu --noconfirm base-devel \ && chown -R nobody: /tmp/cage/ \ - && source /tmp/cage/PKGBUILD && pacman -Syu --noconfirm ${depends[@]} ${makedepends[@]} \ + && source /tmp/cage/PKGBUILD && pacman -S --noconfirm ${depends[@]} ${makedepends[@]} \ && runuser -u nobody -- sh -c "cd /tmp/cage/ && makepkg -c --noconfirm" FROM binhex/arch-base:latest COPY --from=build /tmp/cage/*.pkg.tar.zst /tmp/cage/ -RUN pacman -Syu --noconfirm mesa mesa-libgl wayvnc seatd \ - xorg-xwayland noto-fonts gnu-free-fonts \ - && pacman -U --noconfirm /tmp/cage/*.pkg.tar.zst \ - && yes y | pacman -Scc >/dev/null 2>&1 \ - && rm -rf /usr/share/man/* /usr/share/doc/* \ - /var/cache/pacman/pkg/* /var/lib/pacman/sync/* \ - /tmp/* +COPY build/root/*.sh /root/ +COPY config/ /config/ +COPY supervisor/*.conf /etc/supervisor/conf.d/ -COPY wayvnc.conf /etc/wayvnc/config +RUN chmod +x /root/*.sh && \ + /bin/bash /root/install.sh -ENV PGID=10000 \ - PUID=10000 \ - HOME=/home/user +# TODO, move to install.sh +ENV PUID=10000 \ + PGID=10000 \ + UMASK=022 \ + WAYLAND_DISPLAY=wayland-0 \ + XDG_RUNTIME_DIR=/run/user/${PUID} \ + WLR_BACKENDS=headless \ + WLR_NO_HARDWARE_CURSORS=1 \ + WLR_DRM_DEVICES=/dev/dri/card0 -RUN useradd -U -u ${PGID} -G users,seat,video,render -d "${HOME}" user \ - && mkdir -p /run/user/${PGID} \ - && chown user: /run/user/${PGID} \ - && chmod 7700 /run/user/${PGID} +RUN usermod -a -G seat,video,render nobody \ + && mkdir -p ${XDG_RUNTIME_DIR} \ + && chown ${PUID}:${PGID} ${XDG_RUNTIME_DIR} \ + && chmod 7700 ${XDG_RUNTIME_DIR} -WORKDIR / +EXPOSE 5900 + +CMD ["/bin/bash", "/usr/local/bin/init.sh"] diff --git a/aur-packages b/aur-packages index 5f454d6..a5c019a 160000 --- a/aur-packages +++ b/aur-packages @@ -1 +1 @@ -Subproject commit 5f454d6520b5709b8e0cca6de5a9d40ad6b8f323 +Subproject commit a5c019afc5a210a4296a6474257f9b9a9427b31d diff --git a/build/root/install.sh b/build/root/install.sh new file mode 100644 index 0000000..57d8232 --- /dev/null +++ b/build/root/install.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# exit script if return code != 0 +set -e + +# build scripts +#### + +# download build scripts from github +curl --connect-timeout 5 --max-time 600 --retry 5 --retry-delay 0 --retry-max-time 60 -o /tmp/scripts-master.zip -L https://github.com/binhex/scripts/archive/master.zip + +# unzip build scripts +unzip /tmp/scripts-master.zip -d /tmp + +# move shell scripts to /root +mv /tmp/scripts-master/shell/arch/docker/*.sh /usr/local/bin/ + +# detect image arch +#### + +OS_ARCH=$(cat /etc/os-release | grep -P -o -m 1 "(?=^ID\=).*" | grep -P -o -m 1 "[a-z]+$") +if [[ ! -z "${OS_ARCH}" ]]; then + if [[ "${OS_ARCH}" == "arch" ]]; then + OS_ARCH="x86-64" + else + OS_ARCH="aarch64" + fi + echo "[info] OS_ARCH defined as '${OS_ARCH}'" +else + echo "[warn] Unable to identify OS_ARCH, defaulting to 'x86-64'" + OS_ARCH="x86-64" +fi + +# pacman packages +#### + +# define pacman packages +pacman_packages="mesa mesa-libgl wayvnc seatd xorg-xwayland noto-fonts gnu-free-fonts" + +# install pre-reqs +pacman -S --needed $pacman_packages --noconfirm + +# install locally built cage +pacman -U --noconfirm /tmp/cage/*.pkg.tar.zst + +# env vars +#### +# TODO +mkdir -p /config + +# cleanup +cleanup.sh diff --git a/wayvnc.conf b/config/wayvnc/config similarity index 100% rename from wayvnc.conf rename to config/wayvnc/config diff --git a/supervisor/cage.conf b/supervisor/cage.conf new file mode 100644 index 0000000..4ebe95c --- /dev/null +++ b/supervisor/cage.conf @@ -0,0 +1,4 @@ +[program:cage] +user = nobody +command = /usr/bin/cage %(ENV_APP)s +priority = 50 diff --git a/supervisor/wayvnc.conf b/supervisor/wayvnc.conf new file mode 100644 index 0000000..8ca3f88 --- /dev/null +++ b/supervisor/wayvnc.conf @@ -0,0 +1,4 @@ +[program:wayvnc] +user = nobody +command = /usr/bin/wayvnc -C /config/wayvnc/config -g +priority = 100