-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (34 loc) · 1.32 KB
/
Copy pathDockerfile
File metadata and controls
43 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# ---------- build stage (includes dev deps + build tools for native modules) ----------
FROM node:20-bookworm AS build
WORKDIR /app
# deps
COPY package.json package-lock.json ./
RUN npm ci
# sources needed for both SPA and server builds
COPY tsconfig.json tsconfig.app.json tsconfig.node.json tsconfig.server.json ./
COPY vite.config.ts tailwind.config.js postcss.config.js index.html ./
COPY src ./src
COPY public ./public
COPY server ./server
# Vite build (dist/)
RUN npm run build
# Compile server TS → CommonJS in server-dist/
# The root package.json is "type":"module"; write a tiny package.json in
# server-dist/ so Node treats the compiled output as CommonJS.
RUN npx tsc -p tsconfig.server.json && \
printf '{"type":"commonjs"}\n' > server-dist/package.json
# ---------- runtime stage (slim, production deps only) ----------
FROM node:20-bookworm-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production \
PORT=8080 \
DB_PATH=/data/feedback.db
# install only runtime deps — better-sqlite3 ships a prebuilt for linux-x64-gnu,
# so this is fast and doesn't need gcc on the final image
COPY package.json package-lock.json ./
RUN npm ci --omit=dev && npm cache clean --force
# built artifacts
COPY --from=build /app/dist ./dist
COPY --from=build /app/server-dist ./server
EXPOSE 8080
CMD ["node", "server/index.js"]