-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (44 loc) · 1.42 KB
/
Dockerfile
File metadata and controls
61 lines (44 loc) · 1.42 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
# Multi-stage build for minimal production image
FROM node:22-slim AS builder
# Set working directory
WORKDIR /app
# Copy package files for better layer caching
COPY package*.json ./
COPY tsconfig.json ./
# Install all dependencies (including devDependencies for build)
RUN npm ci --frozen-lockfile
# Copy source code
COPY src/ ./src/
# Build the TypeScript code
RUN npm run build
# Production stage - use slim with minimal footprint
FROM node:22-slim
# Install minimal Java runtime for Specmatic
RUN apt-get update && apt-get install -y \
openjdk-17-jre-headless \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install only production dependencies with clean cache
RUN npm ci --only=production --frozen-lockfile && \
npm cache clean --force && \
rm -rf ~/.npm
# Copy built application from builder stage
COPY --from=builder /app/build ./build
# Create a non-root user (Debian syntax)
RUN groupadd -g 1001 nodejs && \
useradd -r -u 1001 -g nodejs specmatic
# Create reports directory for JUnit XML files
RUN mkdir -p /app/reports && \
chown -R specmatic:nodejs /app
# Switch to non-root user
USER specmatic
# Set environment variables
ENV NODE_ENV=production
# Make the script executable
RUN chmod +x build/index.js
# Override the base image entrypoint and set our MCP server as the default command
ENTRYPOINT []
CMD ["node", "build/index.js"]