Skip to content

Commit

Permalink
chore: Use tsup for building backend
Browse files Browse the repository at this point in the history
  • Loading branch information
mohebifar committed Dec 22, 2024
1 parent 2acd600 commit 1480fe2
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 22 deletions.
5 changes: 4 additions & 1 deletion apps/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ FROM base AS runner
# Copy stuff for prisma to work
COPY --from=installer /app/node_modules/.pnpm/@[email protected][email protected]/node_modules/.prisma/ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/.prisma/

RUN apk update
RUN apk add --no-cache openssl

WORKDIR /app
COPY --from=installer /app/apps/backend ./apps/backend
COPY --from=installer /app/packages/database ./packages/database

CMD cd packages/database && pnpm dlx prisma@latest migrate deploy && cd - && node apps/backend/build/index.js
CMD node apps/backend/build/index.cjs
4 changes: 2 additions & 2 deletions apps/backend/esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ esbuild
bundle: true,
minify: false,
platform: "node",
outfile: "build/index.js",
format: "esm",
outfile: "build/index.cjs",
format: "cjs",
})
.catch(() => process.exit(1));
1 change: 1 addition & 0 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"nodemon": "3.0.2",
"supertest": "catalog:",
"ts-node": "10.9.2",
"tsup": "^8.3.5",
"tsx": "^4.7.1",
"vitest": "1.1.0"
},
Expand Down
2 changes: 0 additions & 2 deletions apps/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "dotenv/config";

import { startCronJobs } from "./cron.js";
import { runServer } from "./server.js";

Expand Down
15 changes: 15 additions & 0 deletions apps/backend/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from "tsup";

export default defineConfig({
entryPoints: ["src/index.ts"],
format: ["cjs"],
dts: false,
sourcemap: true,
clean: true,
minify: false,
splitting: false,
target: "node20",
bundle: true,
outDir: "build",
noExternal: [/(.*)/],
});
5 changes: 3 additions & 2 deletions packages/database/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// https://github.com/prisma/prisma/issues/1787 hangs at prisma issues from 2019

generator client {
provider = "prisma-client-js"
engineType = "binary"
provider = "prisma-client-js"
engineType = "binary"
binaryTargets = ["native", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"]
}

generator json {
Expand Down
Loading

0 comments on commit 1480fe2

Please sign in to comment.