Skip to content

Commit 374b885

Browse files
committed
refactor: move to a shared base image
1 parent 107c08e commit 374b885

File tree

16 files changed

+88
-155
lines changed

16 files changed

+88
-155
lines changed

.github/workflows/docker-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
- name: Set up Docker Buildx
2727
uses: docker/setup-buildx-action@v3
2828
- name: Build the Docker image
29-
run: npm run --prefix ./workspaces build -- --multi-platform --quiet --push
29+
run: npm run --prefix ./workspaces build -- --build-base --multi-platform --push

packages/db/seed.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ const workspaces = [
2525
category: ["Browser"],
2626
icon: "https://www.mozilla.org/media/protocol/img/logos/firefox/browser/logo.eb1324e44442.svg",
2727
},
28-
{
29-
dockerImage: "ghcr.io/spaceness/vscode",
30-
friendlyName: "VSCode",
31-
category: ["Development"],
32-
icon: "https://code.visualstudio.com/assets/apple-touch-icon.png",
33-
},
28+
// {
29+
// dockerImage: "ghcr.io/spaceness/vscode",
30+
// friendlyName: "VSCode",
31+
// category: ["Development"],
32+
// icon: "https://code.visualstudio.com/assets/apple-touch-icon.png",
33+
// },
3434
];
3535
const insertion = await db.insert(workspace).values(workspaces).onConflictDoNothing().returning();
3636
console.log(`✨Stardust: Seeded ${insertion.map((i) => i.dockerImage).join(", ") || "no images"}`);

workspaces/README.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,4 @@
22

33
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.
44

5-
## Building
6-
7-
```bash
8-
pnpm build
9-
```
10-
### Options
11-
12-
`--multi-platform`: Build for both arm64 and amd64. By default, the script builds for your host machine's arch.
13-
14-
`--push`: Push the images to docker registry. This only exists for the GitHub workflow and for devs and serves no purpose to others.
15-
16-
`--quiet`: Suppress logs in the console.
17-
18-
`--images`: Comma separated list of images to build with no spaces e.g. `--images chromium,firefox,zen`
5+
More info in the [Stardust Workspaces Documentation](https://stardust.spaceness.team/docs/development/workspaces)
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ ENV USER=stardust
55
ENV PNPM_HOME="/home/stardust/.local/share/pnpm"
66
ENV DEBIAN_FRONTEND=noninteractive
77

8-
COPY ./scripts /opt/stardust/scripts
9-
# idk if all of these are needed someone fix this - @incognitotgt
8+
COPY ./shared /opt/stardust/shared
9+
1010
RUN apt-get update && apt-get install --no-install-recommends -y \
1111
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 \
12-
python3 python3-pip xterm git procps python3-numpy xfwm4 xfce4-terminal xfce4-session xfconf xfce4-notifyd \
13-
wget curl inetutils-ping vim tigervnc-tools tigervnc-standalone-server tigervnc-common \
14-
{{APPLICATION_PACKAGE}}
12+
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 \
13+
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
1514

16-
RUN bash /opt/stardust/scripts/prepare.sh
15+
RUN bash /opt/stardust/shared/prepare.sh
1716
USER stardust
18-
COPY ./{{NAME}}/xstartup /opt/stardust/xstartup
19-
RUN bash /opt/stardust/scripts/vnc-setup.sh
17+
RUN bash /opt/stardust/shared/vnc-setup.sh
2018

2119
WORKDIR /home/stardust
22-
CMD ["bash", "/opt/stardust/scripts/start.sh"]
2320
EXPOSE 5901 4713 6080
21+
CMD ["bash", "/opt/stardust/shared/start.sh"]

workspaces/build.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,42 @@ function getFlagContents(flag, replacement) {
1919
return replacement;
2020
}
2121

22+
function buildBase() {
23+
console.log("✨ Stardust: Building debian base...");
24+
const multiPlatformBuild = flags.includes("--multi-platform");
25+
return new Promise((resolve, reject) => {
26+
const baseProcess = spawn(
27+
"docker",
28+
[
29+
"buildx",
30+
"build",
31+
".",
32+
"-f",
33+
"base.Dockerfile",
34+
`--progress=${argv.includes("--quiet") ? "quiet" : "plain"}`,
35+
optionalFlag("--push"),
36+
multiPlatformBuild ? "--platform" : "",
37+
multiPlatformBuild ? "linux/amd64,linux/arm64" : "",
38+
"--tag",
39+
"ghcr.io/spaceness/debian-base",
40+
],
41+
{ stdio: "inherit", shell: true },
42+
);
43+
baseProcess.on("close", (code) => {
44+
if (code === 0) {
45+
resolve(0);
46+
} else {
47+
console.error(`✨ Stardust: Failed to build debian base with code ${code}`);
48+
reject(new Error("Build failed for debian base"));
49+
}
50+
});
51+
baseProcess.on("error", (err) => {
52+
console.error(`✨ Stardust: Error while building debian base: ${err.message}`);
53+
reject(err);
54+
});
55+
});
56+
}
57+
2258
function buildImage(image) {
2359
return new Promise((resolve, reject) => {
2460
console.log(`✨ Stardust: Building ${image}...`);
@@ -74,6 +110,9 @@ try {
74110
} else {
75111
images = defaultImages;
76112
}
113+
if (argv.includes("--build-base")) {
114+
await buildBase();
115+
}
77116

78117
await Promise.all(images.map(buildImage));
79118
console.log("✨ Stardust: All images built successfully!");

workspaces/chromium/Dockerfile

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
FROM debian:bookworm
2-
LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust
3-
WORKDIR /opt/stardust
4-
ENV USER=stardust
5-
ENV PNPM_HOME="/home/stardust/.local/share/pnpm"
6-
ENV DEBIAN_FRONTEND=noninteractive
7-
8-
COPY ./scripts /opt/stardust/scripts
9-
10-
RUN apt-get update && apt-get install --no-install-recommends -y \
11-
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 \
12-
python3 python3-pip xterm git procps python3-numpy xfwm4 x11vnc xfce4-terminal xfce4-session xfconf xfce4-notifyd \
13-
wget curl inetutils-ping vim tigervnc-tools tigervnc-standalone-server tigervnc-common wmctrl \
14-
chromium gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
15-
16-
RUN bash /opt/stardust/scripts/prepare.sh
1+
FROM ghcr.io/spaceness/debian-base as base
2+
RUN sudo apt-get update \
3+
&& sudo apt-get install --no-install-recommends -y \
4+
x11vnc \
5+
wmctrl \
6+
chromium
177
USER stardust
18-
COPY ./chromium/xstartup /opt/stardust/xstartup
19-
RUN bash /opt/stardust/scripts/vnc-setup.sh
20-
21-
WORKDIR /home/stardust
22-
CMD ["bash", "/opt/stardust/scripts/start.sh"]
23-
EXPOSE 5901 4713 6080
8+
COPY ./chromium/xstartup /home/stardust/.vnc/xstartup
9+
RUN sudo chmod +x /home/stardust/.vnc/xstartup

workspaces/debian/Dockerfile

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
FROM debian:bookworm
2-
LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust
3-
WORKDIR /opt/stardust
4-
ENV USER=stardust
5-
ENV PNPM_HOME="/home/stardust/.local/share/pnpm"
6-
ENV DEBIAN_FRONTEND=noninteractive
7-
8-
COPY ./scripts /opt/stardust/scripts
9-
1+
FROM ghcr.io/spaceness/debian-base as base
2+
USER root
103
RUN apt-get update && apt-get install --no-install-recommends -y \
11-
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 \
12-
python3 python3-pip xterm git procps python3-numpy neofetch \
13-
xfce4 wget curl xfce4-goodies inetutils-ping firefox-esr chromium gimp remmina remmina-plugin-vnc remmina-plugin-rdp flatpak vim \
14-
tigervnc-tools tigervnc-standalone-server tigervnc-common gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly wmctrl
15-
16-
RUN bash /opt/stardust/scripts/prepare.sh
4+
neofetch \
5+
xfce4 xfce4-goodies \
6+
firefox-esr chromium gimp \
7+
remmina remmina-plugin-vnc remmina-plugin-rdp \
8+
flatpak \
9+
wmctrl \
10+
&& rm -rf /var/lib/apt/lists/*
11+
COPY ./debian/xstartup /home/stardust/.vnc/xstartup
12+
RUN chmod +x /home/stardust/.vnc/xstartup
1713
USER stardust
18-
COPY ./debian/xstartup /opt/stardust/xstartup
19-
RUN bash /opt/stardust/scripts/vnc-setup.sh
20-
21-
WORKDIR /home/stardust
22-
CMD ["bash", "/opt/stardust/scripts/start.sh"]
23-
EXPOSE 5901 4713 6080

workspaces/firefox/Dockerfile

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
1-
FROM debian:bookworm
2-
LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust
3-
WORKDIR /opt/stardust
4-
ENV USER=stardust
5-
ENV PNPM_HOME="/home/stardust/.local/share/pnpm"
6-
ENV DEBIAN_FRONTEND=noninteractive
7-
8-
COPY ./scripts /opt/stardust/scripts
9-
# idk if all of these are needed someone fix this - @incognitotgt
10-
RUN apt-get update && apt-get install --no-install-recommends -y \
11-
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 \
12-
python3 python3-pip procps python3-numpy xfwm4 xfce4-terminal xfce4-session xfconf xfce4-notifyd \
13-
wget curl inetutils-ping vim tigervnc-tools tigervnc-standalone-server tigervnc-common \
14-
firefox-esr
15-
16-
RUN bash /opt/stardust/scripts/prepare.sh
1+
FROM ghcr.io/spaceness/debian-base as base
2+
RUN sudo apt-get update \
3+
&& sudo apt-get install --no-install-recommends -y firefox-esr
174
USER stardust
18-
COPY ./firefox/xstartup /opt/stardust/xstartup
19-
RUN bash /opt/stardust/scripts/vnc-setup.sh
20-
21-
WORKDIR /home/stardust
22-
CMD ["bash", "/opt/stardust/scripts/start.sh"]
23-
EXPOSE 5901 4713 6080
5+
COPY ./firefox/xstartup /home/stardust/.vnc/xstartup
6+
RUN sudo chmod +x /home/stardust/.vnc/xstartup
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ chmod 777 /home/stardust
1010
chmod 777 /opt/stardust
1111
echo "stardust ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
1212
usermod -aG sudo stardust
13-
gcc -o /opt/stardust/tcpulse /opt/stardust/scripts/tcpulse.c
13+
gcc -o /opt/stardust/tcpulse /opt/stardust/shared/tcpulse.c

0 commit comments

Comments
 (0)