Skip to content

Commit 16d9af7

Browse files
committed
ci: simple dockerfile
1 parent bd7c01d commit 16d9af7

File tree

1 file changed

+8
-55
lines changed

1 file changed

+8
-55
lines changed

Dockerfile

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
# Multi-stage build for Mock OpenAI API
1+
# Build stage
22
FROM node:22-alpine AS builder
33

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
155

166
# Copy package files
177
COPY package*.json ./
188

19-
# Install all dependencies (including devDependencies for building)
20-
RUN npm ci && npm cache clean --force
9+
# Install dependencies
10+
RUN npm ci
2111

2212
# Copy source code
2313
COPY . .
@@ -28,45 +18,16 @@ RUN npm run build
2818
# Production stage
2919
FROM node:22-alpine
3020

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
4522

4623
# Copy package files
4724
COPY package*.json ./
4825

49-
# Install only production dependencies
26+
# Install production dependencies
5027
RUN npm ci --only=production && npm cache clean --force
5128

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
7031

7132
# Expose port
7233
EXPOSE 3000
@@ -75,14 +36,6 @@ EXPOSE 3000
7536
ENV NODE_ENV=production
7637
ENV PORT=3000
7738
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", "--"]
8639

8740
# Start the application
8841
CMD ["node", "dist/index.js"]

0 commit comments

Comments
 (0)