1
- # Multi-stage build for Mock OpenAI API
1
+ # Build stage
2
2
FROM node:22-alpine AS builder
3
3
4
- # Add metadata labels
5
- LABEL org.opencontainers.image.title="Mock OpenAI API"
6
- LABEL org.opencontainers.image.description="A complete OpenAI API compatible mock server for development and testing"
7
- LABEL org.opencontainers.image.vendor="zerob13"
8
- LABEL org.opencontainers.image.source="https://github.com/zerob13/mock-openai-api"
9
- LABEL org.opencontainers.image.url="https://hub.docker.com/r/zerob13/mock-openai-api"
10
- LABEL org.opencontainers.image.documentation="https://github.com/zerob13/mock-openai-api#readme"
11
- LABEL org.opencontainers.image.licenses="MIT"
12
-
13
- # Set working directory
14
- WORKDIR /usr/src/app
4
+ WORKDIR /app
15
5
16
6
# Copy package files
17
7
COPY package*.json ./
18
8
19
- # Install all dependencies (including devDependencies for building)
20
- RUN npm ci && npm cache clean --force
9
+ # Install dependencies
10
+ RUN npm ci
21
11
22
12
# Copy source code
23
13
COPY . .
@@ -28,45 +18,16 @@ RUN npm run build
28
18
# Production stage
29
19
FROM node:22-alpine
30
20
31
- # Add metadata labels
32
- LABEL org.opencontainers.image.title="Mock OpenAI API"
33
- LABEL org.opencontainers.image.description="A complete OpenAI API compatible mock server for development and testing"
34
- LABEL org.opencontainers.image.vendor="zerob13"
35
- LABEL org.opencontainers.image.source="https://github.com/zerob13/mock-openai-api"
36
- LABEL org.opencontainers.image.url="https://hub.docker.com/r/zerob13/mock-openai-api"
37
- LABEL org.opencontainers.image.documentation="https://github.com/zerob13/mock-openai-api#readme"
38
- LABEL org.opencontainers.image.licenses="MIT"
39
-
40
- # Install dumb-init for proper signal handling
41
- RUN apk add --no-cache dumb-init
42
-
43
- # Create app directory
44
- WORKDIR /usr/src/app
21
+ WORKDIR /app
45
22
46
23
# Copy package files
47
24
COPY package*.json ./
48
25
49
- # Install only production dependencies
26
+ # Install production dependencies
50
27
RUN npm ci --only=production && npm cache clean --force
51
28
52
- # Copy built application from builder stage
53
- COPY --from=builder /usr/src/app/dist ./dist
54
-
55
- # Copy necessary files
56
- COPY README.md LICENSE ./
57
-
58
- # Create non-root user
59
- RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
60
-
61
- # Change ownership to non-root user
62
- RUN chown -R nextjs:nodejs /usr/src/app
63
- USER nextjs
64
-
65
- # Health check
66
- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
67
- CMD node -e "require('http').get('http://localhost:3000/health', (res) => { \
68
- res.statusCode === 200 ? process.exit(0) : process.exit(1); \
69
- }).on('error', () => process.exit(1));"
29
+ # Copy built application
30
+ COPY --from=builder /app/dist ./dist
70
31
71
32
# Expose port
72
33
EXPOSE 3000
@@ -75,14 +36,6 @@ EXPOSE 3000
75
36
ENV NODE_ENV=production
76
37
ENV PORT=3000
77
38
ENV HOST=0.0.0.0
78
- ENV VERBOSE=false
79
- ENV TZ=UTC
80
- ENV NODE_OPTIONS="--max-old-space-size=256"
81
- ENV NPM_CONFIG_CACHE=/tmp/.npm
82
- ENV NPM_CONFIG_UPDATE_NOTIFIER=false
83
-
84
- # Use dumb-init to handle signals properly
85
- ENTRYPOINT ["dumb-init" , "--" ]
86
39
87
40
# Start the application
88
41
CMD ["node" , "dist/index.js" ]
0 commit comments