File size: 997 Bytes
87cb242
 
 
 
3c81be7
 
87cb242
 
 
 
3c81be7
 
 
87cb242
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM node:20-alpine AS builder
WORKDIR /app

COPY package*.json ./
# Use npm install (no lockfile required). Includes devDeps for tsc.
RUN npm install

COPY . .
RUN npm run build

# Prune devDependencies before copying to runner
RUN npm prune --production

# ── Production image ──────────────────────────────────────────────────────────
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production

# Non-root user for HF container security
RUN addgroup -S appgroup && adduser -S appuser -G appgroup

COPY --from=builder /app/dist         ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

USER appuser

# HF Spaces requires port 7860
EXPOSE 7860

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD wget -qO- http://localhost:7860/health || exit 1

CMD ["node", "dist/index.js"]