diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 24bfb85..162d808 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -26,4 +26,4 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build the Docker image - run: npm run --prefix ./workspaces build -- --multi-platform --quiet --push + run: npm run --prefix ./workspaces build -- --build-base --multi-platform --push diff --git a/packages/db/seed.ts b/packages/db/seed.ts index 43166b7..8aa93bb 100644 --- a/packages/db/seed.ts +++ b/packages/db/seed.ts @@ -25,12 +25,12 @@ const workspaces = [ category: ["Browser"], icon: "https://www.mozilla.org/media/protocol/img/logos/firefox/browser/logo.eb1324e44442.svg", }, - { - dockerImage: "ghcr.io/spaceness/vscode", - friendlyName: "VSCode", - category: ["Development"], - icon: "https://code.visualstudio.com/assets/apple-touch-icon.png", - }, + // { + // dockerImage: "ghcr.io/spaceness/vscode", + // friendlyName: "VSCode", + // category: ["Development"], + // icon: "https://code.visualstudio.com/assets/apple-touch-icon.png", + // }, ]; const insertion = await db.insert(workspace).values(workspaces).onConflictDoNothing().returning(); console.log(`✨Stardust: Seeded ${insertion.map((i) => i.dockerImage).join(", ") || "no images"}`); diff --git a/workspaces/README.md b/workspaces/README.md index 5b44a29..a207000 100644 --- a/workspaces/README.md +++ b/workspaces/README.md @@ -2,17 +2,4 @@ These are the Docker images that are used for Stardust Workspaces. They have a VNC server running, along with a PulseAudio server for audio, and a simple HTTP server for file transfers. -## Building - -```bash -pnpm build -``` -### Options - -`--multi-platform`: Build for both arm64 and amd64. By default, the script builds for your host machine's arch. - -`--push`: Push the images to docker registry. This only exists for the GitHub workflow and for devs and serves no purpose to others. - -`--quiet`: Suppress logs in the console. - -`--images`: Comma separated list of images to build with no spaces e.g. `--images chromium,firefox,zen` \ No newline at end of file +More info in the [Stardust Workspaces Documentation](https://stardust.spaceness.team/docs/development/workspaces) diff --git a/workspaces/template/Dockerfile b/workspaces/base.Dockerfile similarity index 57% rename from workspaces/template/Dockerfile rename to workspaces/base.Dockerfile index cfb2d99..77b2f2d 100644 --- a/workspaces/template/Dockerfile +++ b/workspaces/base.Dockerfile @@ -5,19 +5,17 @@ ENV USER=stardust ENV PNPM_HOME="/home/stardust/.local/share/pnpm" ENV DEBIAN_FRONTEND=noninteractive -COPY ./scripts /opt/stardust/scripts -# idk if all of these are needed someone fix this - @incognitotgt +COPY ./shared /opt/stardust/shared + RUN apt-get update && apt-get install --no-install-recommends -y \ xfonts-75dpi xvfb passwd sudo dbus dbus-x11 libxrandr2 libxext-dev libxrender-dev libxtst-dev imagemagick x11-apps build-essential pulseaudio gstreamer1.0* fonts-noto-color-emoji \ - python3 python3-pip xterm git procps python3-numpy xfwm4 xfce4-terminal xfce4-session xfconf xfce4-notifyd \ - wget curl inetutils-ping vim tigervnc-tools tigervnc-standalone-server tigervnc-common \ - {{APPLICATION_PACKAGE}} + python3 python3-pip xterm git procps python3-numpy xfwm4 xfce4-terminal xfce4-session xfconf xfce4-notifyd wget curl inetutils-ping vim tigervnc-tools tigervnc-standalone-server tigervnc-common \ + gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly -RUN bash /opt/stardust/scripts/prepare.sh +RUN bash /opt/stardust/shared/prepare.sh USER stardust -COPY ./{{NAME}}/xstartup /opt/stardust/xstartup -RUN bash /opt/stardust/scripts/vnc-setup.sh +RUN bash /opt/stardust/shared/vnc-setup.sh WORKDIR /home/stardust -CMD ["bash", "/opt/stardust/scripts/start.sh"] EXPOSE 5901 4713 6080 +CMD ["bash", "/opt/stardust/shared/start.sh"] diff --git a/workspaces/build.js b/workspaces/build.js index d06ed41..f21adf3 100644 --- a/workspaces/build.js +++ b/workspaces/build.js @@ -19,6 +19,42 @@ function getFlagContents(flag, replacement) { return replacement; } +function buildBase() { + console.log("✨ Stardust: Building debian base..."); + const multiPlatformBuild = flags.includes("--multi-platform"); + return new Promise((resolve, reject) => { + const baseProcess = spawn( + "docker", + [ + "buildx", + "build", + ".", + "-f", + "base.Dockerfile", + `--progress=${argv.includes("--quiet") ? "quiet" : "plain"}`, + optionalFlag("--push"), + multiPlatformBuild ? "--platform" : "", + multiPlatformBuild ? "linux/amd64,linux/arm64" : "", + "--tag", + "ghcr.io/spaceness/debian-base", + ], + { stdio: "inherit", shell: true }, + ); + baseProcess.on("close", (code) => { + if (code === 0) { + resolve(0); + } else { + console.error(`✨ Stardust: Failed to build debian base with code ${code}`); + reject(new Error("Build failed for debian base")); + } + }); + baseProcess.on("error", (err) => { + console.error(`✨ Stardust: Error while building debian base: ${err.message}`); + reject(err); + }); + }); +} + function buildImage(image) { return new Promise((resolve, reject) => { console.log(`✨ Stardust: Building ${image}...`); @@ -74,6 +110,9 @@ try { } else { images = defaultImages; } + if (argv.includes("--build-base")) { + await buildBase(); + } await Promise.all(images.map(buildImage)); console.log("✨ Stardust: All images built successfully!"); diff --git a/workspaces/chromium/Dockerfile b/workspaces/chromium/Dockerfile index 0b2b7a9..bde59e2 100644 --- a/workspaces/chromium/Dockerfile +++ b/workspaces/chromium/Dockerfile @@ -1,23 +1,9 @@ -FROM debian:bookworm -LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust -WORKDIR /opt/stardust -ENV USER=stardust -ENV PNPM_HOME="/home/stardust/.local/share/pnpm" -ENV DEBIAN_FRONTEND=noninteractive - -COPY ./scripts /opt/stardust/scripts - -RUN apt-get update && apt-get install --no-install-recommends -y \ - xfonts-75dpi xvfb passwd sudo dbus dbus-x11 libxrandr2 libxext-dev libxrender-dev libxtst-dev imagemagick x11-apps build-essential pulseaudio gstreamer1.0* fonts-noto-color-emoji \ - python3 python3-pip xterm git procps python3-numpy xfwm4 x11vnc xfce4-terminal xfce4-session xfconf xfce4-notifyd \ - wget curl inetutils-ping vim tigervnc-tools tigervnc-standalone-server tigervnc-common wmctrl \ - chromium gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly - -RUN bash /opt/stardust/scripts/prepare.sh +FROM ghcr.io/spaceness/debian-base as base +RUN sudo apt-get update \ + && sudo apt-get install --no-install-recommends -y \ + x11vnc \ + wmctrl \ + chromium USER stardust -COPY ./chromium/xstartup /opt/stardust/xstartup -RUN bash /opt/stardust/scripts/vnc-setup.sh - -WORKDIR /home/stardust -CMD ["bash", "/opt/stardust/scripts/start.sh"] -EXPOSE 5901 4713 6080 +COPY ./chromium/xstartup /home/stardust/.vnc/xstartup +RUN sudo chmod +x /home/stardust/.vnc/xstartup diff --git a/workspaces/debian/Dockerfile b/workspaces/debian/Dockerfile index 020edd8..2f9281f 100644 --- a/workspaces/debian/Dockerfile +++ b/workspaces/debian/Dockerfile @@ -1,23 +1,13 @@ -FROM debian:bookworm -LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust -WORKDIR /opt/stardust -ENV USER=stardust -ENV PNPM_HOME="/home/stardust/.local/share/pnpm" -ENV DEBIAN_FRONTEND=noninteractive - -COPY ./scripts /opt/stardust/scripts - +FROM ghcr.io/spaceness/debian-base as base +USER root RUN apt-get update && apt-get install --no-install-recommends -y \ - xfonts-75dpi xvfb passwd sudo dbus dbus-x11 libxrandr2 libxext-dev libxrender-dev libxtst-dev imagemagick x11-apps build-essential pulseaudio gstreamer1.0* fonts-noto-color-emoji \ - python3 python3-pip xterm git procps python3-numpy neofetch \ - xfce4 wget curl xfce4-goodies inetutils-ping firefox-esr chromium gimp remmina remmina-plugin-vnc remmina-plugin-rdp flatpak vim \ - tigervnc-tools tigervnc-standalone-server tigervnc-common gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly wmctrl - -RUN bash /opt/stardust/scripts/prepare.sh + neofetch \ + xfce4 xfce4-goodies \ + firefox-esr chromium gimp \ + remmina remmina-plugin-vnc remmina-plugin-rdp \ + flatpak \ + wmctrl \ + && rm -rf /var/lib/apt/lists/* +COPY ./debian/xstartup /home/stardust/.vnc/xstartup +RUN chmod +x /home/stardust/.vnc/xstartup USER stardust -COPY ./debian/xstartup /opt/stardust/xstartup -RUN bash /opt/stardust/scripts/vnc-setup.sh - -WORKDIR /home/stardust -CMD ["bash", "/opt/stardust/scripts/start.sh"] -EXPOSE 5901 4713 6080 diff --git a/workspaces/firefox/Dockerfile b/workspaces/firefox/Dockerfile index f9d3b0f..aa4790f 100644 --- a/workspaces/firefox/Dockerfile +++ b/workspaces/firefox/Dockerfile @@ -1,23 +1,6 @@ -FROM debian:bookworm -LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust -WORKDIR /opt/stardust -ENV USER=stardust -ENV PNPM_HOME="/home/stardust/.local/share/pnpm" -ENV DEBIAN_FRONTEND=noninteractive - -COPY ./scripts /opt/stardust/scripts -# idk if all of these are needed someone fix this - @incognitotgt -RUN apt-get update && apt-get install --no-install-recommends -y \ - xfonts-75dpi xvfb passwd sudo dbus dbus-x11 libxrandr2 libxext-dev libxrender-dev libxtst-dev imagemagick x11-apps build-essential pulseaudio gstreamer1.0* fonts-noto-color-emoji \ - python3 python3-pip procps python3-numpy xfwm4 xfce4-terminal xfce4-session xfconf xfce4-notifyd \ - wget curl inetutils-ping vim tigervnc-tools tigervnc-standalone-server tigervnc-common \ - firefox-esr - -RUN bash /opt/stardust/scripts/prepare.sh +FROM ghcr.io/spaceness/debian-base as base +RUN sudo apt-get update \ + && sudo apt-get install --no-install-recommends -y firefox-esr USER stardust -COPY ./firefox/xstartup /opt/stardust/xstartup -RUN bash /opt/stardust/scripts/vnc-setup.sh - -WORKDIR /home/stardust -CMD ["bash", "/opt/stardust/scripts/start.sh"] -EXPOSE 5901 4713 6080 +COPY ./firefox/xstartup /home/stardust/.vnc/xstartup +RUN sudo chmod +x /home/stardust/.vnc/xstartup diff --git a/workspaces/scripts/files.mjs b/workspaces/shared/files.mjs similarity index 100% rename from workspaces/scripts/files.mjs rename to workspaces/shared/files.mjs diff --git a/workspaces/scripts/prepare.sh b/workspaces/shared/prepare.sh similarity index 86% rename from workspaces/scripts/prepare.sh rename to workspaces/shared/prepare.sh index 3f78bb8..750aaf8 100644 --- a/workspaces/scripts/prepare.sh +++ b/workspaces/shared/prepare.sh @@ -10,4 +10,4 @@ chmod 777 /home/stardust chmod 777 /opt/stardust echo "stardust ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers usermod -aG sudo stardust -gcc -o /opt/stardust/tcpulse /opt/stardust/scripts/tcpulse.c +gcc -o /opt/stardust/tcpulse /opt/stardust/shared/tcpulse.c diff --git a/workspaces/scripts/start.sh b/workspaces/shared/start.sh similarity index 91% rename from workspaces/scripts/start.sh rename to workspaces/shared/start.sh index 0c99cd2..9880d21 100644 --- a/workspaces/scripts/start.sh +++ b/workspaces/shared/start.sh @@ -13,7 +13,7 @@ sleep 1 # files echo "while : do -node /opt/stardust/scripts/files.mjs --pass $PASS +node /opt/stardust/shared/files.mjs --pass $PASS sleep 5 done " | bash & diff --git a/workspaces/scripts/tcpulse.c b/workspaces/shared/tcpulse.c similarity index 100% rename from workspaces/scripts/tcpulse.c rename to workspaces/shared/tcpulse.c diff --git a/workspaces/scripts/vnc-setup.sh b/workspaces/shared/vnc-setup.sh similarity index 50% rename from workspaces/scripts/vnc-setup.sh rename to workspaces/shared/vnc-setup.sh index 414a14c..819b966 100644 --- a/workspaces/scripts/vnc-setup.sh +++ b/workspaces/shared/vnc-setup.sh @@ -1,5 +1,3 @@ #!/bin/bash mkdir -p /home/stardust/.vnc touch /home/stardust/.Xresources /home/stardust/.Xauthority -cp /opt/stardust/xstartup /home/stardust/.vnc/xstartup -sudo chmod +x /home/stardust/.vnc/xstartup diff --git a/workspaces/template/xstartup b/workspaces/template/xstartup deleted file mode 100644 index ae92190..0000000 --- a/workspaces/template/xstartup +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -xrdb $HOME/.Xresources -export DISPLAY=":1" -startxfce4 & -sleep 1 -echo "while : -do -{{APPLICATION_COMMAND}} -sleep 2 -done -" | bash diff --git a/workspaces/vscode/Dockerfile b/workspaces/vscode/Dockerfile index 7bb7471..2292f8e 100644 --- a/workspaces/vscode/Dockerfile +++ b/workspaces/vscode/Dockerfile @@ -1,27 +1,8 @@ -## This is currently broken - -FROM debian:bookworm -LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust -WORKDIR /opt/stardust -ENV USER=stardust -ENV PNPM_HOME="/home/stardust/.local/share/pnpm" -ENV DEBIAN_FRONTEND=noninteractive - -COPY ./scripts /opt/stardust/scripts -# idk if all of these are needed someone fix this - @incognitotgt -RUN apt-get update && apt-get install --no-install-recommends -y \ - xfonts-75dpi xvfb passwd sudo dbus dbus-x11 libxrandr2 libxext-dev libxrender-dev libxtst-dev imagemagick x11-apps build-essential pulseaudio gstreamer1.0* fonts-noto-color-emoji \ - python3 python3-pip xterm git procps python3-numpy xfwm4 xfce4-terminal xfce4-session xfconf xfce4-notifyd \ - wget gpg curl inetutils-ping tigervnc-tools tigervnc-standalone-server tigervnc-common - +# broken currently +FROM ghcr.io/spaceness/debian-base as base +USER root COPY ./vscode/install.sh /opt/stardust/scripts/vscode-install.sh - -RUN bash /opt/stardust/scripts/prepare.sh USER stardust RUN bash /opt/stardust/scripts/vscode-install.sh -COPY ./vscode/xstartup /opt/stardust/xstartup -RUN bash /opt/stardust/scripts/vnc-setup.sh - -WORKDIR /home/stardust -CMD ["bash", "/opt/stardust/scripts/start.sh"] -EXPOSE 5901 4713 6080 +COPY ./vscode/xstartup /home/stardust/.vnc/xstartup +RUN sudo chmod +x /home/stardust/.vnc/xstartup diff --git a/workspaces/zen/Dockerfile b/workspaces/zen/Dockerfile index 09c8a24..7f8f14d 100644 --- a/workspaces/zen/Dockerfile +++ b/workspaces/zen/Dockerfile @@ -1,24 +1,6 @@ -FROM debian:bookworm -LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust -WORKDIR /opt/stardust -ENV USER=stardust -ENV PNPM_HOME="/home/stardust/.local/share/pnpm" -ENV DEBIAN_FRONTEND=noninteractive - -COPY ./scripts /opt/stardust/scripts -RUN apt-get update && apt-get install --no-install-recommends -y \ - xfonts-75dpi xvfb passwd sudo dbus dbus-x11 libxrandr2 libxext-dev libxrender-dev libxtst-dev imagemagick x11-apps build-essential pulseaudio gstreamer1.0* fonts-noto-color-emoji \ - python3 python3-pip procps python3-numpy xfwm4 xfce4-terminal xfce4-session xfconf xfce4-notifyd \ - curl inetutils-ping tigervnc-tools tigervnc-standalone-server tigervnc-common - +FROM ghcr.io/spaceness/debian-base as base COPY ./zen/install.sh /opt/stardust/scripts/zen-install.sh - -RUN bash /opt/stardust/scripts/prepare.sh USER stardust RUN bash /opt/stardust/scripts/zen-install.sh -COPY ./zen/xstartup /opt/stardust/xstartup -RUN bash /opt/stardust/scripts/vnc-setup.sh - -WORKDIR /home/stardust -CMD ["bash", "/opt/stardust/scripts/start.sh"] -EXPOSE 5901 4713 6080 +COPY ./zen/xstartup /home/stardust/.vnc/xstartup +RUN sudo chmod +x /home/stardust/.vnc/xstartup