Skip to content

Commit 52f2425

Browse files
author
Nick Maietta
committed
fix: Docker build improvements and website mode enablement
- Add Docker build debugging and library copying for libfacil.io.so - Create entrypoint.sh script for proper library loading - Enable website mode by default in frontend - Clean up redundant README file
1 parent 3f0c7aa commit 52f2425

4 files changed

Lines changed: 58 additions & 37 deletions

File tree

Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ COPY zig/ ./zig/
6666
WORKDIR /app/zig
6767

6868
# Fetch deps + build (add -v for verbose output if debugging)
69-
RUN zig build -Doptimize=ReleaseSafe
69+
# Also ensure libfacil.io.so is copied to a known location
70+
RUN zig build -Doptimize=ReleaseSafe 2>&1 | tee /tmp/build.log || true
71+
RUN mkdir -p /tmp/lib && find /root/.cache/zig/p -name "libfacil.io.so" -exec cp {} /tmp/lib/ \; 2>/dev/null || true
72+
RUN ls -la /tmp/lib/ 2>/dev/null || echo "Library not in cache"
7073

7174

7275
# Stage 3: Final Runtime
@@ -87,6 +90,14 @@ RUN mkdir -p /data/git-repos /app/frontend /app/drizzle
8790
# Copy built backend binary
8891
COPY --from=backend-builder /app/zig/zig-out/bin/selfhost-server /app/selfhost-server
8992

93+
# Copy libfacil.io.so from build cache if available
94+
COPY --from=backend-builder /tmp/lib/libfacil.io.so /usr/local/lib/libfacil.io.so 2>/dev/null || true
95+
RUN ldconfig 2>/dev/null || true
96+
97+
# Copy and setup entrypoint script for library loading
98+
COPY entrypoint.sh /entrypoint.sh
99+
RUN chmod +x /entrypoint.sh
100+
90101
# Frontend assets are now embedded in the binary.
91102
# COPY --from=frontend-builder /app/zig/frontend /app/frontend
92103

@@ -112,5 +123,6 @@ EXPOSE 3000
112123
# Run as non-root user
113124
USER www-data
114125

115-
# Start the server
126+
# Start the server with entrypoint script
127+
ENTRYPOINT ["/entrypoint.sh"]
116128
CMD ["/app/selfhost-server"]

entrypoint.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
echo "Debug: Checking for libfacil.io.so..."
3+
4+
# Find and copy libfacil.io.so to a standard location if needed
5+
if [ ! -f /usr/local/lib/libfacil.io.so ]; then
6+
echo "Library not found in /usr/local/lib, searching..."
7+
8+
# Try to find in project cache first
9+
if [ -d /app ]; then
10+
echo "Searching in /app..."
11+
find /app -name "libfacil.io.so" -exec ls -lh {} \; 2>/dev/null
12+
find /app -name "libfacil.io.so" -exec cp {} /usr/local/lib/libfacil.io.so \; 2>/dev/null
13+
fi
14+
15+
# Also try the global Zig cache
16+
if [ ! -f /usr/local/lib/libfacil.io.so ] && [ -d /root ]; then
17+
echo "Searching in /root/.cache/zig..."
18+
find /root/.cache/zig -name "libfacil.io.so" -exec ls -lh {} \; 2>/dev/null
19+
find /root/.cache/zig -name "libfacil.io.so" -exec cp {} /usr/local/lib/libfacil.io.so \; 2>/dev/null
20+
fi
21+
22+
ldconfig 2>/dev/null || true
23+
fi
24+
25+
# Verify the library exists before starting
26+
if [ ! -f /usr/local/lib/libfacil.io.so ]; then
27+
echo "ERROR: libfacil.io.so not found!"
28+
echo "Contents of /usr/local/lib:"
29+
ls -la /usr/local/lib/ 2>/dev/null | head -10
30+
exit 1
31+
fi
32+
33+
echo "Starting selfhost-server with libfacil.io.so from $(ls -l /usr/local/lib/libfacil.io.so)"
34+
35+
# Start the server
36+
exec /app/selfhost-server

frontend/src/routes/+page.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ export const load: PageLoad = async () => {
2121
: null;
2222
const team = session?.team ?? null;
2323
const teams = user ? await teamsApi.getTeams() : [];
24-
const teamsList = teams.length > 0 ? teams : (team ? [team] : []);
24+
const teamsList = teams.length > 0 ? teams : team ? [team] : [];
2525

2626
try {
2727
const [serversRes, projectsRes] = await Promise.all([
2828
api.get<{ data?: any[] }>('/servers').catch(() => ({ data: [] })),
2929
api.get<{ data?: any[] }>('/projects').catch(() => ({ data: [] }))
3030
]);
31-
const servers = Array.isArray(serversRes.data) ? serversRes.data : (serversRes.data as any)?.data ?? [];
32-
const projects = Array.isArray(projectsRes.data) ? projectsRes.data : (projectsRes.data as any)?.data ?? [];
33-
const websiteMode = false; // TODO: from API /settings/website-mode when available
31+
const servers = Array.isArray(serversRes.data)
32+
? serversRes.data
33+
: ((serversRes.data as any)?.data ?? []);
34+
const projects = Array.isArray(projectsRes.data)
35+
? projectsRes.data
36+
: ((projectsRes.data as any)?.data ?? []);
37+
const websiteMode = true; // TODO: from API /settings/website-mode when available
3438
return {
3539
shouldShowLanding: websiteMode,
3640
shouldUseAppLayout: true,

zig/frontend/README.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)