forked from HackHumanityOrg/pulse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (46 loc) · 1.41 KB
/
Dockerfile
File metadata and controls
67 lines (46 loc) · 1.41 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
# The Brain Service Dockerfile
FROM node:20-alpine AS base
# Dependencies stage - install all dependencies
FROM base AS deps
# libc6-compat may be needed for some native dependencies
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install pnpm
RUN corepack enable pnpm
# Copy package.json files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/shared/package.json ./packages/shared/package.json
COPY apps/the-brain/package.json ./apps/the-brain/package.json
# Install dependencies
RUN pnpm install --frozen-lockfile
# Build stage - compile the application
FROM base AS builder
WORKDIR /app
RUN corepack enable pnpm
# Copy the prepared pnpm workspace, including package-local node_modules links.
COPY --from=deps /app/ ./
# Copy source code
COPY . .
# Build shared package first
RUN pnpm build:shared
# Build the-brain
RUN pnpm build:the-brain
# Runtime stage - production image
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Install pnpm
RUN corepack enable pnpm
# Create non-root user for security
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
# Copy built application
COPY --from=builder /app/apps/the-brain/dist ./dist
COPY --from=builder /app/apps/the-brain/package.json ./package.json
# Copy node_modules for runtime
COPY --from=builder /app/node_modules ./node_modules
USER nodejs
ENV HEALTH_PORT=3001
ENV PORT=3001
EXPOSE 3001
CMD ["pnpm", "start"]