-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
113 lines (85 loc) · 2.64 KB
/
Dockerfile
File metadata and controls
113 lines (85 loc) · 2.64 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Multi-stage Docker build for CodeMind API
FROM node:20-slim AS base
# Set working directory
WORKDIR /app
# Install system dependencies including Python for native builds
RUN apt-get update && apt-get install -y \
postgresql-client \
curl \
bash \
python3 \
make \
g++ \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -g 1001 codemind && \
useradd -u 1001 -g codemind -m codemind
# Development stage
FROM base AS development
# Copy package files
COPY package*.json ./
# Install all dependencies (including dev dependencies)
RUN npm ci --include=dev
# Copy source code
COPY --chown=codemind:codemind . .
# Expose development port
EXPOSE 3004
# Switch to non-root user
USER codemind
# Development command
CMD ["npm", "run", "dev"]
# Production build stage
FROM base AS builder
# Copy package files
COPY package*.json ./
COPY tsconfig.json ./
# Install all dependencies (including dev for build)
RUN npm ci && npm cache clean --force
# Copy source code
COPY . .
# Build TypeScript
RUN npm run build
# Production stage
FROM node:20-slim AS production
# Install production system dependencies
RUN apt-get update && apt-get install -y \
postgresql-client \
curl \
bash \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -g 1001 codemind && \
useradd -u 1001 -g codemind -m codemind
# Set working directory
WORKDIR /app
# Install production dependencies only
COPY --from=builder --chown=codemind:codemind /app/package*.json ./
RUN npm ci --omit=dev && npm cache clean --force
# Copy built application from builder stage
COPY --from=builder --chown=codemind:codemind /app/dist ./dist
COPY --from=builder --chown=codemind:codemind /app/src ./src
# Create logs directory
RUN mkdir -p /app/logs && chown codemind:codemind /app/logs
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3004
ENV LOG_LEVEL=info
# Expose port
EXPOSE 3004
# Switch to non-root user
USER codemind
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:3004/health || exit 1
# Start the API server
CMD ["node", "dist/api/server.js"]
# Metadata labels
LABEL maintainer="CodeMind Team <team@codemind.dev>" \
version="0.1.0" \
description="CodeMind API - Intelligent code analysis and orchestration" \
org.opencontainers.image.title="CodeMind API" \
org.opencontainers.image.description="API service for CodeMind intelligent code orchestration" \
org.opencontainers.image.vendor="CodeMind" \
org.opencontainers.image.version="0.1.0" \
org.opencontainers.image.schema-version="1.0"