Skip to content

Commit 107c08e

Browse files
committed
chore: start vsc workspace, bug fixes in admin dash, format code
1 parent b6e5e4b commit 107c08e

File tree

7 files changed

+88
-17
lines changed

7 files changed

+88
-17
lines changed

apps/web/src/app/(main)/admin/workspaces/actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ export async function deleteImageFromNode(workspace: SelectWorkspace, nId: strin
6868
const connector = stardustConnector(node);
6969
const { data, error } = await connector.workspaces.info.delete(undefined, { query: { id: workspace.dockerImage } });
7070
if (error) throw new Error(error.value.message);
71+
revalidatePath("/admin/workspaces");
7172
return data;
7273
}

apps/web/src/app/(main)/admin/workspaces/components.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,18 @@ export function NodeDialog({ workspace, open, setOpen }: Props) {
9494
<Button
9595
variant="destructive"
9696
onClick={() =>
97-
toast.promise(() => deleteImageFromNode(workspace, nodeWorkspace.id), {
98-
loading: "Removing from node",
99-
success: "Removed from node",
100-
error: "Failed to remove from node",
101-
})
97+
toast.promise(
98+
async () => {
99+
const promise = await deleteImageFromNode(workspace, nodeWorkspace.id);
100+
mutate();
101+
return promise;
102+
},
103+
{
104+
loading: "Removing from node",
105+
success: "Removed from node",
106+
error: "Failed to remove from node",
107+
},
108+
)
102109
}
103110
>
104111
Remove from node

packages/db/seed.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +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+
},
2834
];
2935
const insertion = await db.insert(workspace).values(workspaces).onConflictDoNothing().returning();
3036
console.log(`✨Stardust: Seeded ${insertion.map((i) => i.dockerImage).join(", ") || "no images"}`);

workspaces/build.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ const flags = args.filter((value) => value.startsWith("--"));
1010

1111
const optionalFlag = (flag) => (flags.includes(flag) ? flag : "");
1212

13-
function getFlagContents (flag, replacement) {
14-
const indexOf = flags.indexOf(flag)
15-
const nextArg = args[indexOf + 1]
16-
if (indexOf != -1 && nextArg) {
17-
return nextArg
18-
} else {
19-
return replacement
13+
function getFlagContents(flag, replacement) {
14+
const indexOf = flags.indexOf(flag);
15+
const nextArg = args[indexOf + 1];
16+
if (indexOf !== -1 && nextArg) {
17+
return nextArg;
2018
}
19+
return replacement;
2120
}
2221

2322
function buildImage(image) {
@@ -34,15 +33,23 @@ function buildImage(image) {
3433
".",
3534
"-f",
3635
`${image}/Dockerfile`,
37-
optionalFlag("--quiet"),
36+
`--progress=${argv.includes("--quiet") ? "quiet" : "plain"}`,
3837
optionalFlag("--push"),
3938
multiPlatformBuild ? "--platform" : "",
4039
multiPlatformBuild ? platforms : "",
4140
"--tag",
4241
`ghcr.io/spaceness/${image}`,
4342
],
44-
{ stdio: "inherit", shell: true },
43+
{ stdio: ["inherit", "pipe", "pipe"], shell: true },
4544
);
45+
46+
process.stdout.on("data", (data) => {
47+
globalThis.process.stdout.write(`${image}: ${data}`);
48+
});
49+
50+
process.stderr.on("data", (data) => {
51+
globalThis.process.stderr.write(`${image}: ${data}`);
52+
});
4653
process.on("close", (code) => {
4754
if (code === 0) {
4855
resolve(0);
@@ -60,12 +67,12 @@ function buildImage(image) {
6067
}
6168

6269
try {
63-
let images = getFlagContents("--images", undefined)
70+
let images = getFlagContents("--images", undefined);
6471

6572
if (images) {
66-
images = images.split(',')
73+
images = images.split(",");
6774
} else {
68-
images = defaultImages
75+
images = defaultImages;
6976
}
7077

7178
await Promise.all(images.map(buildImage));

workspaces/vscode/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## This is currently broken
2+
3+
FROM debian:bookworm
4+
LABEL org.opencontainers.image.source=https://github.com/spaceness/stardust
5+
WORKDIR /opt/stardust
6+
ENV USER=stardust
7+
ENV PNPM_HOME="/home/stardust/.local/share/pnpm"
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
10+
COPY ./scripts /opt/stardust/scripts
11+
# idk if all of these are needed someone fix this - @incognitotgt
12+
RUN apt-get update && apt-get install --no-install-recommends -y \
13+
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 \
14+
python3 python3-pip xterm git procps python3-numpy xfwm4 xfce4-terminal xfce4-session xfconf xfce4-notifyd \
15+
wget gpg curl inetutils-ping tigervnc-tools tigervnc-standalone-server tigervnc-common
16+
17+
COPY ./vscode/install.sh /opt/stardust/scripts/vscode-install.sh
18+
19+
RUN bash /opt/stardust/scripts/prepare.sh
20+
USER stardust
21+
RUN bash /opt/stardust/scripts/vscode-install.sh
22+
COPY ./vscode/xstartup /opt/stardust/xstartup
23+
RUN bash /opt/stardust/scripts/vnc-setup.sh
24+
25+
WORKDIR /home/stardust
26+
CMD ["bash", "/opt/stardust/scripts/start.sh"]
27+
EXPOSE 5901 4713 6080

workspaces/vscode/install.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
download_url="https://code.visualstudio.com/sha/download?build=stable&os=linux-$(dpkg-architecture -q DEB_BUILD_ARCH)"
4+
echo "Installing VSCode..."
5+
echo "Downloading"
6+
echo $download_url
7+
curl -fSL $download_url -o /tmp/vscode.tar.gz
8+
echo "Extracting"
9+
mkdir -p /home/stardust/.local/share/vscode
10+
tar --strip-components=1 -xzf /tmp/vscode.tar.gz -C /home/stardust/.local/share/vscode
11+
echo "Success!"

workspaces/vscode/xstartup

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
xrdb $HOME/.Xresources
3+
export DISPLAY=":1"
4+
startxfce4 &
5+
sleep 1
6+
sudo service dbus start
7+
echo "while :
8+
do
9+
/home/stardust/.local/share/vscode/bin/code --no-sandbox --verbose --wait
10+
sleep 2
11+
done
12+
" | bash

0 commit comments

Comments
 (0)