diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 9fb5df3..a2ffb6f 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -34,6 +34,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - + name: Permissions fixes + run: | + reponame="$(basename ${GITHUB_REPOSITORY})" + target="${HOME}/work/${reponame}/${reponame}/build/COPY*" + chmod -R ug+rwX ${target} - name: Login to GitHub Container Registry uses: docker/login-action@v2 @@ -96,6 +102,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - + name: Permissions fixes + run: | + reponame="$(basename ${GITHUB_REPOSITORY})" + target="${HOME}/work/${reponame}/${reponame}/build/COPY*" + chmod -R ug+rwX ${target} - name: Login to GitHub Container Registry uses: docker/login-action@v2 @@ -154,6 +166,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - + name: Permissions fixes + run: | + reponame="$(basename ${GITHUB_REPOSITORY})" + target="${HOME}/work/${reponame}/${reponame}/build/COPY*" + chmod -R ug+rwX ${target} - name: Login to GitHub Container Registry uses: docker/login-action@v2 diff --git a/.gitignore b/.gitignore index 0386930..50f2079 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ workspace -build/COPY_ROOT_EXTRA config/authorized_keys config/rclone .env diff --git a/build/COPY_ROOT/opt/ai-dock/bin/preflight.sh b/build/COPY_ROOT/opt/ai-dock/bin/preflight.d/20-desktop.sh similarity index 68% rename from build/COPY_ROOT/opt/ai-dock/bin/preflight.sh rename to build/COPY_ROOT/opt/ai-dock/bin/preflight.d/20-desktop.sh index a107692..58c5b29 100755 --- a/build/COPY_ROOT/opt/ai-dock/bin/preflight.sh +++ b/build/COPY_ROOT/opt/ai-dock/bin/preflight.d/20-desktop.sh @@ -3,11 +3,12 @@ # This file will be sourced in init.sh function preflight_main() { - desktop_dir="${WORKSPACE}/home/${USER_NAME}/Desktop" + home_dir="/home/${USER_NAME}" + desktop_dir="${home_dir}/Desktop" mkdir -p ${desktop_dir} chown ${USER_NAME}.${USER_NAME} "${desktop_dir}" + ln -sf "${home_dir}" "${desktop_dir}" ln -sf "${WORKSPACE}" "${desktop_dir}" - locale-gen $LANG } diff --git a/build/COPY_ROOT/opt/ai-dock/bin/preflight.d/30-steam.sh b/build/COPY_ROOT/opt/ai-dock/bin/preflight.d/30-steam.sh new file mode 100644 index 0000000..cf1e074 --- /dev/null +++ b/build/COPY_ROOT/opt/ai-dock/bin/preflight.d/30-steam.sh @@ -0,0 +1,9 @@ +mkdir -p /opt/ai-dock/lib/steam-native + +steam_dir="${home_dir}"/.steam/debian-installation/ +proton_compat_dir="${steam_dir}/compatibilitytools.d/${GE_PROTON_VERSION}" +proton_binary_path="/opt/proton/${GE_PROTON_VERSION}/proton" +mkdir -p "${proton_compat_dir}" +cp /opt/ai-dock/share/proton/* "${proton_compat_dir}" +sed -i "s#PROTON_NAME#${GE_PROTON_VERSION}#g" "${proton_compat_dir}/compatibilitytool.vdf" +sed -i "s#PROTON_BINARY_PATH#${proton_binary_path}#g" "${proton_compat_dir}/toolmanifest.vdf" \ No newline at end of file diff --git a/build/COPY_ROOT/opt/ai-dock/bin/supervisor-x-server.sh b/build/COPY_ROOT/opt/ai-dock/bin/supervisor-x-server.sh index bfbf33b..d40546d 100755 --- a/build/COPY_ROOT/opt/ai-dock/bin/supervisor-x-server.sh +++ b/build/COPY_ROOT/opt/ai-dock/bin/supervisor-x-server.sh @@ -13,6 +13,8 @@ function cleanup() { } function start() { + source /opt/ai-dock/etc/environment.sh + if [[ ${SERVERLESS,,} = "true" ]]; then printf "Refusing to start $SERVICE_NAME in serverless mode\n" exec sleep 10 @@ -29,7 +31,7 @@ function start() { # This symbolic link enables running Xorg inside a container with `-sharevts` sudo ln -snf /dev/ptmx /dev/tty7 sudo mkdir -pm700 /tmp/runtime-user - sudo chown ${USER_NAME}:${USER_NAME} /tmp/runtime-user + sudo chown $(id -u):$(id -u) /tmp/runtime-user if [[ $XPU_TARGET == "NVIDIA_GPU" && $(is_nvidia_capable) == "true" ]]; then printf "Starting NVIDIA X server...\n" diff --git a/build/COPY_ROOT_EXTRA/opt/ai-dock/bin/build/layer1/init.sh b/build/COPY_ROOT_EXTRA/opt/ai-dock/bin/build/layer1/init.sh index 185f297..d3bedbd 100755 --- a/build/COPY_ROOT_EXTRA/opt/ai-dock/bin/build/layer1/init.sh +++ b/build/COPY_ROOT_EXTRA/opt/ai-dock/bin/build/layer1/init.sh @@ -1,5 +1,5 @@ #!/bin/bash - +set -eo pipefail # Override this file to add extras to your build umask 002 # Wine, Winetricks, Lutris, and PlayOnLinux, this process must be consistent with https://wiki.winehq.org/Ubuntu @@ -13,7 +13,8 @@ apt-get install --install-recommends -y \ apt-get install --no-install-recommends -y \ q4wine \ playonlinux -LUTRIS_VERSION="$(curl -fsSL "https://api.github.com/repos/lutris/lutris/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g')" +export LUTRIS_VERSION="$(curl -fsSL "https://api.github.com/repos/lutris/lutris/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g')" +env-store LUTRIS_VERSION curl -fsSL -O "https://github.com/lutris/lutris/releases/download/v${LUTRIS_VERSION}/lutris_${LUTRIS_VERSION}_all.deb" apt-get install --no-install-recommends -y ./lutris_${LUTRIS_VERSION}_all.deb && rm -f "./lutris_${LUTRIS_VERSION}_all.deb" curl -fsSL -o /usr/bin/winetricks "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" @@ -29,17 +30,47 @@ apt-get install --install-recommends -y \ libreoffice-style-breeze # Steam +export GE_PROTON_VERSION="$(curl -fsSL "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases/latest" | jq -r '.tag_name')" +env-store GE_PROTON_VERSION +mkdir -p /opt/proton +wget -c "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/${GE_PROTON_VERSION}/${GE_PROTON_VERSION}.tar.gz" -O - | tar xz -C /opt/proton +dpkg-divert --add /usr/games/steam $APT_INSTALL \ - steam-installer + steam-installer \ + libpipewire-0.3-0:i386 \ + libxcb-res0:i386 \ + libgtk2.0-0:i386 +cp -f /opt/ai-dock/share/steam/bin/steam /usr/games/steam +chmod +x /usr/games/steam +cp -f /opt/ai-dock/share/steam/bin/steam-native /usr/bin/steam-native +chmod +x /usr/bin/steam-native ln -sf /usr/games/steam /usr/bin/steam # Graphics utils - +apt-get update $APT_INSTALL \ blender \ blender-data \ gimp \ inkscape +mkdir -p /opt/krita +wget -O /opt/krita/krita.appimage https://download.kde.org/stable/krita/5.2.2/krita-5.2.2-x86_64.appimage +chmod +x /opt/krita/krita.appimage +(cd /opt/krita && /opt/krita/krita.appimage --appimage-extract) +rm -f /opt/krita/krita.appimage +cp -rf /opt/krita/squashfs-root/usr/share/{applications,icons} /usr/share/ +chmod +x /opt/ai-dock/bin/krita + +# Chrome +wget -O /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +$APT_INSTALL /tmp/chrome.deb +dpkg-divert --add /opt/google/chrome/google-chrome +cp -f /opt/google/chrome/google-chrome /opt/google/chrome/google-chrome.distrib +cp -f /opt/ai-dock/share/google-chrome/bin/google-chrome /opt/google/chrome/google-chrome + + +rm -rf /tmp/* + fix-permissions -o container \ No newline at end of file diff --git a/build/COPY_ROOT_EXTRA/opt/ai-dock/bin/krita b/build/COPY_ROOT_EXTRA/opt/ai-dock/bin/krita new file mode 100755 index 0000000..694b89e --- /dev/null +++ b/build/COPY_ROOT_EXTRA/opt/ai-dock/bin/krita @@ -0,0 +1,3 @@ +#!/bin/bash + +exec /opt/krita/squashfs-root/AppRun "$@" \ No newline at end of file diff --git a/build/COPY_ROOT_EXTRA/opt/ai-dock/share/google-chrome/bin/google-chrome b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/google-chrome/bin/google-chrome new file mode 100755 index 0000000..8cf31aa --- /dev/null +++ b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/google-chrome/bin/google-chrome @@ -0,0 +1,3 @@ +#!/bin/bash + +exec /opt/google/chrome/google-chrome.distrib --no-sandbox "$@" \ No newline at end of file diff --git a/build/COPY_ROOT_EXTRA/opt/ai-dock/share/proton/compatibilitytool.vdf b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/proton/compatibilitytool.vdf new file mode 100644 index 0000000..2c794fa --- /dev/null +++ b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/proton/compatibilitytool.vdf @@ -0,0 +1,13 @@ +"compatibilitytools" +{ + "compat_tools" + { + "PROTON_NAME" + { + "install_path" "." + "display_name" "PROTON_NAME (No SLR)" + "from_oslist" "windows" + "to_oslist" "linux" + } + } +} \ No newline at end of file diff --git a/build/COPY_ROOT_EXTRA/opt/ai-dock/share/proton/toolmanifest.vdf b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/proton/toolmanifest.vdf new file mode 100644 index 0000000..b8dc077 --- /dev/null +++ b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/proton/toolmanifest.vdf @@ -0,0 +1,5 @@ +"manifest" +{ + "version" "2" + "commandline" "'PROTON_BINARY_PATH' %verb%" +} \ No newline at end of file diff --git a/build/COPY_ROOT_EXTRA/opt/ai-dock/share/steam/bin/steam b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/steam/bin/steam new file mode 100755 index 0000000..b93dda7 --- /dev/null +++ b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/steam/bin/steam @@ -0,0 +1,118 @@ +#!/bin/sh -e +# Copyright (C) 2013-2018 Michael Gilbert +# Copyright (C) 2018-2020 Simon McVittie +# Copyright (C) 2020 Collabora Ltd. +# License: MIT + +# Used by diagnostic tools to identify the launcher +export STEAMSCRIPT="$0" +# Edited by debian/rules to fill in the real version number +export STEAMSCRIPT_VERSION='1.0.0.74-1ubuntu2/Ubuntu' + +# According to Valve, ~/.steam is intended to be a control directory containing +# symbolic links pointing to the currently-running or most-recently-run Steam +# installation. This is part of Steam's API, and is relied on by external +# components. +# +# The shell variable name STEAMCONFIG matches what's used in Valve's +# /usr/bin/steam (available at $STEAMDIR/bin_steam.sh in a Steam +# installation). +STEAMCONFIG="$HOME/.steam" + +: "${XDG_DATA_HOME:="$HOME/.local/share"}" + +# Fix dangling symlinks +if [ -L "$STEAMCONFIG/steam" ] && ! [ -e "$STEAMCONFIG/steam" ]; then + rm -f "$STEAMCONFIG/steam" +fi +if [ -L "$STEAMCONFIG/root" ] && ! [ -e "$STEAMCONFIG/root" ]; then + rm -f "$STEAMCONFIG/root" +fi + +# STEAMDIR points to the actual installation root: the equivalent of +# C:\Program Files\Steam in the Windows Steam client. To avoid filename +# collisions this should be distinct from ~/.steam. +# +# The shell variable name STEAMDIR matches what's used in Valve's +# /usr/bin/steam (bin_steam.sh). +# +# Strictly speaking, there can be two separate Steam directories: +# ~/.steam/steam is a symlink to the Steam data directory (containing +# e.g. games), while ~/.steam/root is a symlink to the Steam installation +# (containing the Steam executable and the Steam Runtime). This is used +# when testing new Steam client binaries, and older versions of this Debian +# package set up a similar situation by mistake. +if [ -L "$STEAMCONFIG/steam" ]; then + STEAMDIR="$(readlink -e -q "$STEAMCONFIG/steam")" +elif [ -L "$STEAMCONFIG/root" ]; then + STEAMDIR="$(readlink -e -q "$STEAMCONFIG/root")" +elif [ -d "$STEAMCONFIG/steam" ] && ! [ -L "$STEAMCONFIG/steam" ]; then + # The historical Debian behaviour has been to use ~/.steam as the + # installation directory in addition to using it as the control + # directory.This causes some file collisions, so we've moved away + # from that, but we can't easily disentangle this in existing + # installations. + STEAMDIR="$HOME/.steam" +else + # This is a new installation, so use a distinct directory to avoid + # file collisions. Valve would use $XDG_DATA_HOME/Steam here. + # Debian uses a subdirectory of ~/.steam, to avoid having a mixture + # of XDG basedirs and traditional dotfiles in the same application. + STEAMDIR="$HOME/.steam/debian-installation" +fi + +ubuntu32="$STEAMDIR/ubuntu12_32" +steam="$ubuntu32/steam" +runtime="$ubuntu32/steam-runtime" + +real=/usr/lib/games/steam/steam + +# use C locale (bug #764311) +test -n "$LANG" || export LANG=C + +# check wether this system supports sse2 +nosse2="\ +WARNING: +The hardware on this system lacks support for the sse2 instruction set. +The browser within the steam client will not work. For more information, +see: https://support.steampowered.com/kb_article.php?ref=4090-RTKZ-4347" +if ! grep -q sse2 /proc/cpuinfo; then + echo "$nosse2" +fi + +# do an initial update when expected pieces are missing +test ! -d "$STEAMCONFIG" && rm -rf "$STEAMCONFIG" && mkdir -p "$STEAMCONFIG" || true +test ! -d "$STEAMDIR" && rm -rf "$STEAMDIR" && mkdir -p "$STEAMDIR" || true + +# Recent versions of the proprietary steam executable exit with an +# assertion failure if these links aren't already set up. +if ! [ -d "$STEAMCONFIG/steam" ]; then + ln -fns "$STEAMDIR" "$STEAMCONFIG/steam" +fi +if ! [ -d "$STEAMCONFIG/root" ]; then + ln -fns "$STEAMDIR" "$STEAMCONFIG/root" +fi + +test ! -x "$STEAMDIR/steam.sh" && rm -rf "$STEAMDIR/package" "$steam" || true +test ! -d "$ubuntu32" && rm -rf "$ubuntu32" && mkdir -p "$ubuntu32" || true +test ! -x "$steam" && rm -rf "$steam" && cp "$real" "$steam" && "$steam" || true +test ! -e "$runtime.tar.xz" && cat "$runtime.tar.xz.part"* > "$runtime.tar.xz" || true +test ! -d "$runtime" && cd "$ubuntu32" && tar xf steam-runtime.tar.xz && \ + md5sum steam-runtime.tar.xz > steam-runtime/checksum || \ + rm -f steam-runtime.tar.xz* + +## AI-Dock edit +if [ -n "$STEAM_ARCHIVE_ID" ] && [ ! -f "$STEAMDIR/.downgrade_complete" ]; then + kdialog --passivepopup "Downgrading steam client to latest working version" 10 --title "Steam Installer" & + printf "BootStrapperInhibitAll=enable\nBootStrapperForceSelfUpdate=disable" > "$STEAMDIR/Steam.cfg" + "$STEAMDIR/steam.sh" -forcesteamupdate -forcepackagedownload -overridepackageurl "https://web.archive.org/web/${STEAM_ARCHIVE_ID}if_/media.steampowered.com/client" -exitsteam && \ + touch "$STEAMDIR/.downgrade_complete" +fi + +# Remove old log file to avoid confusion. To debug game/Steam issues, +# please run this script from an interactive terminal, run it with its +# stdout/stderr redirected, or wrap it with script(1). +rm -f "$STEAMDIR/error.log" + +# launch the Valve run script +test -x "$STEAMDIR/steam.sh" && exec "$STEAMDIR/steam.sh" -nominidumps -nobreakpad -noverifyfiles -nobootstrapupdate -skipinitialbootstrap -norepairfiles "$@" diff --git a/build/COPY_ROOT_EXTRA/opt/ai-dock/share/steam/bin/steam-native b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/steam/bin/steam-native new file mode 100755 index 0000000..2d72bd2 --- /dev/null +++ b/build/COPY_ROOT_EXTRA/opt/ai-dock/share/steam/bin/steam-native @@ -0,0 +1,11 @@ +#!/bin/bash + +printf "Broken. Need to fix - RB" +exit 0 +export STEAM_RUNTIME=0 +export STEAM_RUNTIME_HEAVY=0 +# Workaround for dbus fatal termination related coredumps (SIGABRT) +# https://github.com/ValveSoftware/steam-for-linux/issues/4464 +export DBUS_FATAL_WARNINGS=0 +export LD_LIBRARY_PATH="/opt/ai-dock/lib/steam-native${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" +exec /usr/bin/steam "$@" diff --git a/build/Dockerfile b/build/Dockerfile index 953a473..aa8c6f4 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -62,6 +62,8 @@ ENV APPIMAGE_EXTRACT_AND_RUN 1 ARG WINE_BRANCH=staging ENV WINE_BRANCH=${WINE_BRANCH} +ARG STEAM_ARCHIVE_ID=20240216110829 +ENV STEAM_ARCHIVE_ID=${STEAM_ARCHIVE_ID} # Copy early so we can use scripts in the build - Changes to these files will invalidate the cache and cause a rebuild. COPY --chown=0:1111 ./COPY_ROOT/ / diff --git a/docker-compose.yaml b/docker-compose.yaml index cb266c2..9f39a05 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,7 +7,7 @@ services: args: IMAGE_BASE: ${IMAGE_BASE:-ghcr.io/ai-dock/base-image:cuda-11.8.0-runtime-22.04} tags: - - "ghcr.io/ai-dock/desktop:${IMAGE_TAG:-cuda-11.8.0-runtime-22.04}" + - "ghcr.io/ai-dock/linux-desktop:${IMAGE_TAG:-cuda-11.8.0-runtime-22.04}" image: ghcr.io/ai-dock/linux-desktop:${IMAGE_TAG:-cuda-11.8.0-base-22.04} @@ -89,4 +89,4 @@ services: # Magic bullet to solve networking issues - I don't like it # Turn server works fine both within local network and for internet - #network_mode: "host" \ No newline at end of file + #network_mode: "host"