-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (32 loc) · 1.16 KB
/
Dockerfile
File metadata and controls
40 lines (32 loc) · 1.16 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
# syntax=docker/dockerfile:1.4
# Stage 1: Dependencies
FROM node:20-alpine AS deps
WORKDIR /app
COPY package*.json ./
# Install all dependencies (including devDependencies like 'vite')
# We need 'vite' because server.ts uses a static import for it in strict ESM mode
RUN --mount=type=cache,target=/root/.npm npm ci
# Stage 2: Builder
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build the application
RUN npm run build
# Stage 3: Runner
FROM node:20-alpine AS runner
WORKDIR /app
# In production, we only need basic node environment since rendering is client-side
ENV NODE_ENV=production
ENV PORT=3000
# Copy node_modules from deps - keep all including vite for static import
COPY --from=deps --chown=node:node /app/node_modules ./node_modules
COPY --from=builder --chown=node:node /app/dist ./dist
COPY --chown=node:node public ./public
COPY --chown=node:node server.ts ./
# Copy config files just in case tsx/vite needs them for resolution
COPY --chown=node:node tsconfig*.json ./
COPY --chown=node:node vite.config.ts ./
EXPOSE 3000
USER node
CMD ["npx", "tsx", "server.ts"]