ArchiveAds commited on
Commit
e41a26d
·
verified ·
1 Parent(s): 6969582

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -21
Dockerfile CHANGED
@@ -1,12 +1,12 @@
1
  # Use official Node.js image
2
- FROM node:18-slim
3
 
4
- # Install FFmpeg and required fonts
5
- # We install libnss3 and other libs required for Tesseract/Canvas if needed later
6
  RUN apt-get update && apt-get install -y \
7
  ffmpeg \
8
  wget \
9
- fonts-liberation \
10
  libgl1-mesa-glx \
11
  libnss3 \
12
  libatk1.0-0 \
@@ -22,33 +22,28 @@ RUN apt-get update && apt-get install -y \
22
  libasound2 \
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
- # Create app directory
26
  WORKDIR /usr/src/app
27
 
28
- # Copy package files
29
  COPY package*.json ./
30
 
31
- # Install dependencies
32
- RUN npm install
33
 
34
- # Pre-download Tesseract Language Data (English) to prevent runtime timeout
35
  RUN mkdir -p tessdata && \
36
  wget -O ./tessdata/eng.traineddata https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata
37
 
38
- # Bundle app source
39
  COPY . .
40
 
41
- # Create necessary folders for temp storage
42
- RUN mkdir -p videos processed downloads
43
 
44
- # FIX: Grant permission to the 'node' user
45
- RUN chown -R node:node /usr/src/app
46
-
47
- # Switch to 'node' user for security and permission consistency
48
- USER node
49
-
50
- # Expose port 7860 for Hugging Face
51
  EXPOSE 7860
52
 
53
- # Start the application
54
- CMD [ "node", "server.js" ]
 
 
1
  # Use official Node.js image
2
+ FROM node:18
3
 
4
+ # Install FFmpeg, wget, and dependencies for Tesseract/Canvas
5
+ # We include 'procps' so PM2 can manage processes
6
  RUN apt-get update && apt-get install -y \
7
  ffmpeg \
8
  wget \
9
+ procps \
10
  libgl1-mesa-glx \
11
  libnss3 \
12
  libatk1.0-0 \
 
22
  libasound2 \
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
+ # Set working directory
26
  WORKDIR /usr/src/app
27
 
28
+ # Copy package files first (better caching)
29
  COPY package*.json ./
30
 
31
+ # Install dependencies AND PM2 globally
32
+ RUN npm install && npm install -g pm2
33
 
34
+ # Pre-download Tesseract Language Data to avoid runtime timeouts
35
  RUN mkdir -p tessdata && \
36
  wget -O ./tessdata/eng.traineddata https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata
37
 
38
+ # Copy the rest of the app
39
  COPY . .
40
 
41
+ # Create temp folders and ensure they are writable (Running as root, so chmod 777 ensures everything works)
42
+ RUN mkdir -p videos processed downloads && chmod -R 777 videos processed downloads
43
 
44
+ # Expose the correct port
 
 
 
 
 
 
45
  EXPOSE 7860
46
 
47
+ # Start with PM2 (Production Process Manager)
48
+ # --no-daemon keeps the container alive
49
+ CMD ["pm2-runtime", "server.js"]