diff --git a/.github/workflows/CI-build.yml b/.github/workflows/CI-build.yml index 61c4801..bdd7b02 100644 --- a/.github/workflows/CI-build.yml +++ b/.github/workflows/CI-build.yml @@ -2,9 +2,7 @@ name: Build with Bun on: push: - branches: [main] pull_request: - branches: [main] jobs: build: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..251df77 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Use Bun official image +FROM oven/bun:latest + +WORKDIR /app + +# Copy root files and install root dependencies +# Copy root and workspace manifests +COPY package.json bun.lock ./ +COPY packages/server/package.json ./packages/server/ +COPY packages/client/package.json ./packages/client/ + +# Install dependencies with full workspace context +RUN bun install + +# Copy the rest of the monorepo +COPY . . + +# Build both packages +RUN bun run build + +# Expose ports (adjust as needed) +EXPOSE 3000 + +# Start both client and server +CMD ["bun", "start.ts"] \ No newline at end of file diff --git a/start.ts b/start.ts new file mode 100644 index 0000000..99e9aa1 --- /dev/null +++ b/start.ts @@ -0,0 +1,32 @@ +// start.ts +import { serve } from "bun"; +import express from "express"; +import dotenv from "dotenv"; +import router from "./packages/server/routes"; // adjust path if needed +import path from "path"; +import { readFile } from "fs/promises"; + +dotenv.config(); + +const app = express(); +app.use(express.json()); +app.use("/", router); // mount your API routes in the root + +const clientDist = path.resolve(import.meta.dir, "packages/client/dist"); + +// Serve static files +app.use(express.static(clientDist)); + +// Spa fallback with named fallback +app.get("/*splat", async (_, res) => { + const indexPath = path.join(clientDist, "index.html"); + const html = await readFile(indexPath, "utf-8"); + res.setHeader("Content-Type", "text/html"); + res.send(html); +}); + +// Start server +const port = process.env.PORT || 3000; +app.listen(port, () => { + console.log(`Unified app running at http://localhost:${port}`); +});