-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (43 loc) · 2.11 KB
/
Dockerfile
File metadata and controls
61 lines (43 loc) · 2.11 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
# ══════════════════════════════════════════════════════════════════════════════
# RETE - Multi-stage Docker build
# ══════════════════════════════════════════════════════════════════════════════
# ── Stage 1: Build ────────────────────────────────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies first (better layer caching)
COPY package.json package-lock.json ./
RUN npm ci
# Copy source files
COPY . .
# Build the application (frontend + backend)
RUN npm run build
# ── Stage 2: Production ───────────────────────────────────────────────────────
FROM node:20-alpine AS production
WORKDIR /app
# Install only production dependencies
COPY package.json package-lock.json ./
RUN npm ci --omit=dev && npm cache clean --force
# Copy built artifacts from builder stage
COPY --from=builder /app/dist ./dist
# Copy database schema for migrations
COPY shared ./shared
COPY drizzle.config.ts ./
# Install drizzle-kit for migrations (needed at runtime for db:push)
RUN npm install drizzle-kit
# Copy entrypoint script
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S rete -u 1001 -G nodejs
USER rete
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:5000/api/auth/me || exit 1
# Set environment defaults
ENV NODE_ENV=production
ENV PORT=5000
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["node", "dist/index.cjs"]