File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ FROM node:24-alpine AS builder
2+
3+ RUN corepack enable && corepack prepare
[email protected] --activate
4+
5+ WORKDIR /app
6+
7+ COPY package.json pnpm-workspace.yaml pnpm-lock.yaml .npmrc ./
8+ COPY tsconfig.json tsconfig.base.json ./
9+ COPY lib/ ./lib/
10+ COPY artifacts/ ./artifacts/
11+ COPY scripts/ ./scripts/
12+
13+ RUN pnpm install --frozen-lockfile
14+
15+ RUN PORT=3000 BASE_PATH=/ NODE_ENV=production \
16+ pnpm --filter @workspace/images-dashboard run build
17+
18+ RUN pnpm --filter @workspace/api-server run build
19+
20+ FROM node:24-alpine AS runner
21+
22+ WORKDIR /app
23+
24+ COPY --from=builder /app/artifacts/api-server/dist/ ./dist/
25+ COPY --from=builder /app/artifacts/images-dashboard/dist/public/ ./dist/public/
26+
27+ ENV NODE_ENV=production
28+ ENV PORT=8080
29+ EXPOSE 8080
30+
31+ CMD ["node" , "--enable-source-maps" , "dist/index.mjs" ]
Original file line number Diff line number Diff line change 11import express , { type Express } from "express" ;
22import cors from "cors" ;
33import pinoHttp from "pino-http" ;
4+ import path from "path" ;
5+ import { fileURLToPath } from "url" ;
46import router from "./routes" ;
57import { logger } from "./lib/logger" ;
68
@@ -31,4 +33,12 @@ app.use(express.urlencoded({ extended: true }));
3133
3234app . use ( "/api" , router ) ;
3335
36+ if ( process . env [ "NODE_ENV" ] === "production" ) {
37+ const publicDir = path . join ( path . dirname ( fileURLToPath ( import . meta. url ) ) , "public" ) ;
38+ app . use ( express . static ( publicDir ) ) ;
39+ app . get ( "*" , ( _req , res ) => {
40+ res . sendFile ( path . join ( publicDir , "index.html" ) ) ;
41+ } ) ;
42+ }
43+
3444export default app ;
You can’t perform that action at this time.
0 commit comments