forked from Streampay-Org/StreamPay-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (45 loc) · 1.47 KB
/
Dockerfile
File metadata and controls
61 lines (45 loc) · 1.47 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
# Stage 1: Dependencies
FROM node:20-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# Stage 2: Builder
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Stage 3: API Runner (Default target)
FROM node:20-alpine AS api-runner
WORKDIR /app
ENV NODE_ENV production
# Hardening: Run as non-root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 streampay
# Hardening: Minimal set of files using Next.js standalone
COPY --from=builder /app/public ./public
COPY --from=builder --chown=streampay:nodejs /app/.next/standalone ./
COPY --from=builder --chown=streampay:nodejs /app/.next/static ./.next/static
USER streampay
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
# Healthcheck to verify app is running
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/readyz || exit 1
CMD ["node", "server.js"]
# Stage 4: Worker Runner
FROM node:20-alpine AS worker-runner
WORKDIR /app
ENV NODE_ENV production
# Hardening: Run as non-root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 streampay
# Hardening: Only include necessary files for worker
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN rm -rf .next app public
USER streampay
# Worker command
CMD ["node", "scripts/run-from-realpath.mjs", "ts-node", "scripts/reconcile-streams.ts"]