mrpoddaa commited on
Commit
e78789c
Β·
verified Β·
1 Parent(s): 9d6d5f6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +5 -28
Dockerfile CHANGED
@@ -1,50 +1,27 @@
1
  # ╔══════════════════════════════════════════════════════════════════╗
2
  # β•‘ Telegram File Storage β€” Dockerfile (HF CPU Basic 16GB RAM) β•‘
3
- # β•‘ β€’ Optimized for 16GB RAM containers β•‘
4
- # β•‘ β€’ 8192MB Node heap limit (was 1024MB) β•‘
5
- # β•‘ β€’ Garbage collection enabled β•‘
6
- # β•‘ β€’ Secure MongoDB Atlas connection β•‘
7
  # β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
8
  FROM node:20-slim
9
 
10
- # ── Install CA certs + OpenSSL compat tools ─────────────────────────────────
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
- ca-certificates \
13
- openssl \
14
  && update-ca-certificates \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
- # ── HF Spaces runs as non-root uid 1000 ─────────────────────────────────────
18
  RUN useradd -m -u 1000 appuser 2>/dev/null || true
19
 
20
  WORKDIR /app
21
-
22
- # ── Copy package files first (layer caching optimization) ───────────────────
23
  COPY package.json ./
 
 
24
 
25
- # ── Install dependencies (production only) ──────────────────────────────────
26
- RUN npm install --production --no-audit --no-fund && \
27
- npm cache clean --force
28
-
29
- # ── Copy application source ─────────────────────────────────────────────────
30
- COPY index.js ./
31
- COPY strings.html ./
32
-
33
- # ── CRITICAL: Node.js Memory + GC Settings ──────────────────────────────────
34
- # --max-old-space-size=8192 β†’ 8GB heap (safe for 16GB RAM container) ← UPDATED
35
- # --expose-gc β†’ Enable manual garbage collection
36
- # --openssl-legacy-provider β†’ MongoDB Atlas TLS compatibility
37
  ENV NODE_OPTIONS="--max-old-space-size=8192 --expose-gc --openssl-legacy-provider"
38
 
39
- # ── Hugging Face Spaces required port ───────────────────────────────────────
40
  EXPOSE 7860
41
-
42
- # ── Switch to non-root user (security) ──────────────────────────────────────
43
  USER 1000
44
 
45
- # ── Health check (30s interval) ─────────────────────────────────────────────
46
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
47
- CMD node -e "require('http').get('http://localhost:7860/health', (r) => { process.exit(r.statusCode === 200 ? 0 : 1); });"
48
 
49
- # ── Start application ───────────────────────────────────────────────────────
50
  CMD ["node", "index.js"]
 
1
  # ╔══════════════════════════════════════════════════════════════════╗
2
  # β•‘ Telegram File Storage β€” Dockerfile (HF CPU Basic 16GB RAM) β•‘
 
 
 
 
3
  # β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
4
  FROM node:20-slim
5
 
 
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ ca-certificates openssl \
 
8
  && update-ca-certificates \
9
  && rm -rf /var/lib/apt/lists/*
10
 
 
11
  RUN useradd -m -u 1000 appuser 2>/dev/null || true
12
 
13
  WORKDIR /app
 
 
14
  COPY package.json ./
15
+ RUN npm install --production --no-audit --no-fund && npm cache clean --force
16
+ COPY index.js strings.html ./
17
 
18
+ # 8GB heap for 16GB RAM server
 
 
 
 
 
 
 
 
 
 
 
19
  ENV NODE_OPTIONS="--max-old-space-size=8192 --expose-gc --openssl-legacy-provider"
20
 
 
21
  EXPOSE 7860
 
 
22
  USER 1000
23
 
 
24
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
25
+ CMD node -e "require('http').get('http://localhost:7860/health',(r)=>{process.exit(r.statusCode===200?0:1)});"
26
 
 
27
  CMD ["node", "index.js"]