forked from Open-audit-foundation/Open-Audit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.worker
More file actions
76 lines (59 loc) · 2.23 KB
/
Copy pathDockerfile.worker
File metadata and controls
76 lines (59 loc) · 2.23 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
# ============================================================================
# Dockerfile for Stellar Indexer Worker
# ============================================================================
# This Dockerfile builds an isolated container for the indexer worker that:
# - Polls/streams Stellar blockchain
# - Processes and translates events
# - Publishes to Redis Pub/Sub
#
# Build: docker build -f Dockerfile.worker -t open-audit-worker .
# Run: docker run --env-file .env open-audit-worker
# ============================================================================
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
RUN npm ci
# ============================================================================
# Builder stage
# ============================================================================
FROM base AS builder
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Generate Prisma client if using database
RUN if [ -d "prisma" ]; then npx prisma generate; fi
# Build TypeScript (if needed)
# RUN npm run build:worker
# ============================================================================
# Runner stage - Production image
# ============================================================================
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 worker
# Copy necessary files
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/lib ./lib
COPY --from=builder /app/src ./src
COPY --from=builder /app/tsconfig.json ./
COPY --from=builder /app/tsconfig.server.json ./
# Copy Prisma files if exists
COPY --from=builder /app/prisma ./prisma
# Set permissions
RUN chown -R worker:nodejs /app
# Switch to non-root user
USER worker
# Expose port for health checks (optional)
EXPOSE 9090
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD node -e "process.exit(0)"
# Start the worker
CMD ["npx", "ts-node", "--project", "tsconfig.server.json", "src/worker/indexer.ts"]