Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (46 loc) · 1.43 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (46 loc) · 1.43 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
FROM node:20-alpine AS base
# Build stage
FROM base AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY tsconfig.json ./
COPY vite.config.ts ./
COPY tailwind.config.ts ./
COPY postcss.config.js ./
# Install dependencies
RUN npm ci
# Copy source code
COPY client ./client
COPY server ./server
COPY shared ./shared
# Build client
RUN npm run build
# Build server (compile TypeScript to JavaScript)
RUN npx tsc --project tsconfig.json
# Production stage
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --omit=dev
# Copy built application (client build output)
COPY --from=builder /app/dist ./dist
# Copy compiled server code (if using separate server build)
# or source files if running with tsx/ts-node
COPY --from=builder /app/server ./server
COPY --from=builder /app/shared ./shared
# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
RUN chown -R nodejs:nodejs /app
USER nodejs
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=30s \
CMD wget -qO /dev/null http://localhost:${PORT:-3000}/api/v1/health/live || exit 1
# Note: Running TypeScript files directly with tsx in production
# If you prefer compiled JavaScript, update build process and use:
# CMD ["node", "dist/server/index.js"]
CMD ["node", "--import", "tsx", "server/index.ts"]