-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (33 loc) · 1017 Bytes
/
Dockerfile
File metadata and controls
48 lines (33 loc) · 1017 Bytes
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
# Multi-stage build for Penpot MCP Server
FROM node:18-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY tsconfig.json ./
# Install dependencies (ignore scripts since src is not copied yet)
RUN npm ci --ignore-scripts
# Copy source files
COPY src ./src
# Build
RUN npm run build
# Production stage
FROM node:18-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Copy built files from builder first
COPY --from=builder /app/dist ./dist
# Install production dependencies only (ignore scripts since we already have built files)
RUN npm ci --only=production --ignore-scripts && npm cache clean --force
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
# Change ownership
RUN chown -R nodejs:nodejs /app
# Switch to non-root user
USER nodejs
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "console.log('healthy')" || exit 1
# Run the server
CMD ["node", "dist/index.js"]