-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (37 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
49 lines (37 loc) · 1.27 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
# Museum Management REST API — multi-stage build (smallest image)
# =============================================================
# Stage 1: Dependencies and build
FROM node:20-alpine AS builder
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile
COPY tsconfig.json ./
COPY index.ts app.ts ./
COPY types types/
COPY config config/
COPY middlewares middlewares/
COPY server server/
COPY drizzle.config.ts ./
COPY drizzle drizzle/
RUN pnpm run build
# Prune dev dependencies so runner only gets production node_modules
RUN pnpm prune --prod
# Stage 2: Production runner (minimal: no pnpm, no dev deps)
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=5001
# Copy only runtime artifacts from builder (no source, no devDependencies)
COPY --from=builder /app/package.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/drizzle ./drizzle
COPY --from=builder /app/drizzle.config.ts ./
# Landing page at GET / (public/index.html)
COPY public ./public/
# Non-root user for security
RUN addgroup -g 1001 -S app && adduser -u 1001 -S app -G app
USER app
EXPOSE ${PORT}
CMD ["node", "dist/index.js"]