From 73929347b0e6fc40d9a0b6e96ff952e90f2a33d2 Mon Sep 17 00:00:00 2001 From: aliofye Date: Tue, 14 Jan 2025 19:52:34 -0500 Subject: [PATCH 1/2] Build backend as a single file executable on prod --- .docker/Dockerfile.prod | 2 +- packages/api/package.json | 3 ++- packages/web/package.json | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.docker/Dockerfile.prod b/.docker/Dockerfile.prod index 486dde9..5bc50c1 100644 --- a/.docker/Dockerfile.prod +++ b/.docker/Dockerfile.prod @@ -14,7 +14,7 @@ COPY bun.lockb package.json ./ COPY packages ./packages RUN bun install -# Build the frontend +# Build the frontend and backend RUN bun run build # Install dependencies required for Caddy installation diff --git a/packages/api/package.json b/packages/api/package.json index a1174ba..b2c74e8 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -4,8 +4,9 @@ "private": true, "description": "Backend", "scripts": { - "start": "bun src/app.ts", + "start": "./dist/app", "dev": "bun --hot src/app.ts", + "build": "bun build --compile src/app.ts --outfile dist/app", "compile": "tsc -b --noEmit && tsc-alias", "test": "DATABASE_URL=$TEST_DATABASE_URL sh -c \"bun run db:migrate && bun test\"", "test:watch": "DATABASE_URL=$TEST_DATABASE_URL sh -c \"bun run db:migrate && bun test --watch\"", diff --git a/packages/web/package.json b/packages/web/package.json index 70293e4..133c36b 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -5,7 +5,6 @@ "description": "Frontend", "scripts": { "dev": "vite", - "preview": "vite preview", "build": "vite build", "compile": "tsc -b --noEmit && tsc-alias", "test": "bun test", From aae1c316c9433c8d5e585695c59c49e43746b2e7 Mon Sep 17 00:00:00 2001 From: aliofye Date: Tue, 14 Jan 2025 20:17:00 -0500 Subject: [PATCH 2/2] Follow recommended bun docs for build command --- packages/api/.gitignore | 5 ++++- packages/api/package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/api/.gitignore b/packages/api/.gitignore index ce007ac..8556ab4 100644 --- a/packages/api/.gitignore +++ b/packages/api/.gitignore @@ -172,4 +172,7 @@ dist .idea # Finder (MacOS) folder config -.DS_Store \ No newline at end of file +.DS_Store + +# Bun +*.bun-build \ No newline at end of file diff --git a/packages/api/package.json b/packages/api/package.json index b2c74e8..60658c6 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -6,7 +6,7 @@ "scripts": { "start": "./dist/app", "dev": "bun --hot src/app.ts", - "build": "bun build --compile src/app.ts --outfile dist/app", + "build": "bun build --compile --minify --sourcemap --bytecode src/app.ts --outfile dist/app", "compile": "tsc -b --noEmit && tsc-alias", "test": "DATABASE_URL=$TEST_DATABASE_URL sh -c \"bun run db:migrate && bun test\"", "test:watch": "DATABASE_URL=$TEST_DATABASE_URL sh -c \"bun run db:migrate && bun test --watch\"",