File size: 1,261 Bytes
5383ef0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ── Build stage ──────────────────────────────────────────────────────────────
FROM node:20-slim AS base

WORKDIR /app

# Copy package files first for better layer caching
COPY package.json ./
RUN npm install --omit=dev

# Copy everything else
COPY . .

# ── Runtime ───────────────────────────────────────────────────────────────────
FROM node:20-slim

# HuggingFace Spaces run as non-root user (uid 1000)
RUN groupadd -g 1000 appuser && \
    useradd -u 1000 -g appuser -s /bin/sh -m appuser

WORKDIR /app

# Copy installed modules and app code
COPY --from=base /app /app

RUN chown -R appuser:appuser /app

USER appuser

# HuggingFace requires the app to listen on port 7860
EXPOSE 7860

ENV PORT=7860
ENV NODE_ENV=production

# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD node -e "require('http').get('http://localhost:7860/health', r => process.exit(r.statusCode===200?0:1)).on('error',()=>process.exit(1))"

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