-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathDockerfile.dev
More file actions
40 lines (29 loc) · 1.07 KB
/
Copy pathDockerfile.dev
File metadata and controls
40 lines (29 loc) · 1.07 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
# Self-contained Docker build following the exact optimization pattern from reference
# Stage 1 - Builder
FROM oven/bun:1 AS builder
WORKDIR /app
# Copy package files first (for better layer caching)
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
# Copy source code and build
COPY . .
RUN bun run build
# Clean node_modules and install only production dependencies
RUN rm -rf node_modules && bun install --frozen-lockfile --production
# Stage 2 - Runtime: Pure Alpine with only Node.js runtime
FROM alpine AS runtime
WORKDIR /app
# Install only Node.js runtime (saves 50-80MB vs node:22-alpine)
RUN apk add --no-cache nodejs-lts
# Copy only what's needed for production
COPY --from=builder /app/package.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.output ./.output
# Set runtime environment
ENV NODE_ENV=production
ENV PORT=3000
# Add healthcheck
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
EXPOSE 3000
CMD ["node", ".output/server/index.mjs"]