Akwbw commited on
Commit
a990a46
·
verified ·
1 Parent(s): 524897e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -11
Dockerfile CHANGED
@@ -1,10 +1,10 @@
1
- # Step 1: Node.js version 18 use karenge
2
  FROM node:18
3
 
4
- # Step 2: Chrome aur REDIS (Database) install karenge
5
- # Redis zaroori hai warna app start hokar band ho jayegi
6
  RUN apt-get update && apt-get install -y \
7
  redis-server \
 
 
8
  libnss3 \
9
  libnspr4 \
10
  libatk1.0-0 \
@@ -22,22 +22,32 @@ RUN apt-get update && apt-get install -y \
22
  libgtk-3-0 \
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
- # Step 3: Folder set karo
26
  WORKDIR /app
27
 
28
- # Step 4: Code Clone karo
29
  RUN git clone https://github.com/Shelex/free-otp-api.git .
30
 
31
- # Step 5: Dependencies install (Legacy mode to avoid errors)
32
  RUN npm install --legacy-peer-deps
33
 
34
- # Step 6: Environment Variables
 
 
 
35
  ENV PORT=7860
36
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false
37
 
38
- # Step 7: Port Open karo
 
 
 
 
 
 
 
 
39
  EXPOSE 7860
40
 
41
- # Step 8: START COMMAND (Bahut Important)
42
- # Pehle Redis chalega background mein, phir App start hogi
43
- CMD redis-server --daemonize yes && npm start
 
 
1
  FROM node:18
2
 
3
+ # 1. Install Chrome (Puppeteer) and Redis
 
4
  RUN apt-get update && apt-get install -y \
5
  redis-server \
6
+ wget \
7
+ gnupg \
8
  libnss3 \
9
  libnspr4 \
10
  libatk1.0-0 \
 
22
  libgtk-3-0 \
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
+ # 2. Setup App Directory
26
  WORKDIR /app
27
 
28
+ # 3. Clone the Repo
29
  RUN git clone https://github.com/Shelex/free-otp-api.git .
30
 
31
+ # 4. Install Dependencies (Legacy Peer Deps to fix version issues)
32
  RUN npm install --legacy-peer-deps
33
 
34
+ # 5. Fix Redis Connection (Force IPv4)
35
+ # Hum Node ko batayenge ki localhost ka matlab 127.0.0.1 hai, ::1 nahi
36
+ ENV REDIS_HOST=127.0.0.1
37
+ ENV REDIS_PORT=6379
38
  ENV PORT=7860
39
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false
40
 
41
+ # 6. Create a Startup Script (Yeh hai Permanent Fix)
42
+ # Yeh script pehle Redis chalayegi, confirm karegi, phir app start karegi
43
+ RUN echo "#!/bin/bash\n\
44
+ redis-server --daemonize yes\n\
45
+ echo 'Waiting for Redis to start...'\n\
46
+ sleep 5\n\
47
+ npm start" > start.sh && chmod +x start.sh
48
+
49
+ # 7. Open Port
50
  EXPOSE 7860
51
 
52
+ # 8. Run the Script
53
+ CMD ["./start.sh"]