-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (59 loc) · 2.42 KB
/
Dockerfile
File metadata and controls
80 lines (59 loc) · 2.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Multi-stage Dockerfile for Countly MCP Server
# Optimized for production use with minimal image size
# Stage 1: Build
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY tsconfig.json ./
COPY tsconfig.build.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY src ./src
# Build TypeScript
RUN npm run build
# Stage 2: Production
FROM node:20-alpine
# OCI Labels for metadata and Docker Desktop icon
LABEL org.opencontainers.image.title="Countly MCP Server" \
org.opencontainers.image.description="Model Context Protocol server for Countly Analytics Platform" \
org.opencontainers.image.vendor="Countly" \
org.opencontainers.image.authors="Countly Team" \
org.opencontainers.image.url="https://count.ly" \
org.opencontainers.image.documentation="https://github.com/countly/countly-mcp-server" \
org.opencontainers.image.source="https://github.com/countly/countly-mcp-server" \
org.opencontainers.image.licenses="MIT" \
com.docker.extension.icon="https://cdn.prod.website-files.com/61c1b7c3e2f3805325be4594/63cc3bf4993f0072054270a6_Logo%20-%20Dark%20background.png"
WORKDIR /app
# Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init
# Create a non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
# Copy package files and install production dependencies only
COPY package*.json ./
RUN npm ci --omit=dev && \
npm cache clean --force
# Copy built files from builder stage
COPY --from=builder /app/build ./build
# Copy other necessary files
COPY --chown=nodejs:nodejs .env.example ./.env.example
# Create directory for token files (useful for Docker secrets)
RUN mkdir -p /run/secrets && \
chown -R nodejs:nodejs /run/secrets
# Switch to non-root user
USER nodejs
# Environment variables (can be overridden)
ENV NODE_ENV=production \
COUNTLY_SERVER_URL=https://api.count.ly \
COUNTLY_TIMEOUT=30000
# Expose port for HTTP mode
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" || exit 1
# Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
# Default command: run in HTTP mode on port 3000 (can be overridden for stdio mode)
CMD ["node", "build/index.js", "--http", "--port", "3000", "--hostname", "0.0.0.0"]