Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# GuacaMalla Net — backend image (Railway / Docker). Also builds and bundles
# the marketing/waitlist page (web/landing), which the backend serves as
# static files at GET / (see backend/src/index.ts) — one image, one service.
# the marketing/waitlist page (guacamalla-landing/landing), which the backend
# serves as static files at GET / (see backend/src/index.ts) — one image, one
# service.
#
# IMPORTANT: build context is the REPO ROOT, not backend/. The backend imports
# @guacamaya/shared (a Bun `workspace:*` package) and backend/tsconfig.json
Expand All @@ -19,18 +20,23 @@ WORKDIR /app
COPY package.json bun.lock ./
COPY backend/package.json ./backend/package.json
COPY packages/shared/package.json ./packages/shared/package.json
COPY web/landing/package.json ./web/landing/package.json
RUN bun install --frozen-lockfile

# The landing is NOT a root workspace — it ships its own bun.lock/bunfig
# (self-contained Vite app), so it gets its own cached install layer.
COPY guacamalla-landing/landing/package.json guacamalla-landing/landing/bun.lock guacamalla-landing/landing/bunfig.toml ./guacamalla-landing/landing/
RUN bun install --frozen-lockfile --cwd guacamalla-landing/landing

# 2) Copy the source. node_modules is excluded via .dockerignore so this does
# not clobber the installed deps from the layer above.
# not clobber the installed deps from the layers above.
COPY packages/ ./packages/
COPY backend/ ./backend/
COPY web/landing/ ./web/landing/
COPY guacamalla-landing/landing/ ./guacamalla-landing/landing/

# 3) Build the landing page to static files (web/landing/dist) — no SSR, no
# server needed at runtime, the backend just serves the compiled output.
RUN bun run --cwd web/landing build
# 3) Build the landing page to static files (guacamalla-landing/landing/dist) —
# no SSR, no server needed at runtime, the backend just serves the compiled
# output.
RUN bun run --cwd guacamalla-landing/landing build

# Production by design: the server refuses to boot without GUACAMAYA_ADMIN_KEY
# (set it, and the rest, as Railway Variables — see backend/.env.example).
Expand Down
15 changes: 9 additions & 6 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ await app.register(waitlistRoutes);

app.get("/health", async () => ({ ok: true }));

// Serves the compiled marketing/waitlist page (web/landing) at GET / and its
// asset paths — same origin as the API, so the waitlist form needs no CORS
// config. Falls back to a JSON message if the frontend hasn't been built
// (e.g. a fresh checkout that only ran `bun run dev:backend`).
const LANDING_DIST = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../web/landing/dist");
// Serves the compiled marketing/waitlist page (guacamalla-landing/landing) at
// GET / and its asset paths — same origin as the API, so the waitlist form
// needs no CORS config. Falls back to a JSON message if the frontend hasn't
// been built (e.g. a fresh checkout that only ran `bun run dev:backend`).
const LANDING_DIST = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"../../guacamalla-landing/landing/dist",
);
if (fs.existsSync(path.join(LANDING_DIST, "index.html"))) {
await app.register(fastifyStatic, { root: LANDING_DIST });
} else {
app.log.warn(
`Landing page build not found at ${LANDING_DIST} — GET / falls back to a JSON message. ` +
"Run 'bun run --cwd web/landing build' to serve the real page.",
"Run 'bun run --cwd guacamalla-landing/landing build' to serve the real page.",
);
app.get("/", async () => ({ message: "Welcome to GuacaMalla Net!" }));
}
Expand Down
887 changes: 9 additions & 878 deletions bun.lock

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why to chance the path 'web/landing' to 'guacamalla-landing/landing', seems unnecessary redundant (?)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
"private": true,
"workspaces": [
"packages/*",
"backend",
"web/*"
"backend"
],
"scripts": {
"dev:backend": "bun run --cwd backend dev",
"dev:landing": "bun run --cwd web/landing dev",
"build": "bun run --cwd packages/shared build && bun run --cwd backend build && bun run --cwd web/landing build",
"dev:landing": "bun run --cwd guacamalla-landing/landing dev",
"build": "bun run --cwd packages/shared build && bun run --cwd backend build && bun run --cwd guacamalla-landing/landing build",
"test": "bun test",
"keygen": "bun run backend/src/security/keygen.ts"
},
Expand Down