storage / Dockerfile
mrpoddaa's picture
Update Dockerfile
2f5e032 verified
# ──────────────────────────────────────────────
# TG Store Β· Dockerfile for Hugging Face Spaces
# ──────────────────────────────────────────────
FROM node:20-slim
# node:20-slim strips CA certificates β€” MongoDB Atlas TLS will fail without this
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# node:20-slim already ships with a 'node' user at uid 1000
# DO NOT run useradd β€” uid 1000 already exists and will crash the build
WORKDIR /app
# Install dependencies first (better layer caching)
COPY package.json ./
RUN npm install --omit=dev
# Copy application source with correct ownership
COPY --chown=node:node . .
# Hugging Face Spaces requires port 7860
ENV PORT=7860
ENV NODE_OPTIONS=--use-openssl-ca
EXPOSE 7860
# Use the built-in node user (uid 1000) β€” required by HF Spaces
USER node
# HF pings /system to verify the app is alive
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s \
CMD node -e "require('http').get('http://localhost:7860/system',r=>{process.exit(r.statusCode===200?0:1)}).on('error',()=>process.exit(1))"
CMD ["node", "index.js"]