File size: 3,122 Bytes
56b6d1b
 
 
 
3b399e8
56b6d1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b399e8
56b6d1b
 
 
 
 
 
 
 
 
 
 
3b399e8
56b6d1b
3b399e8
56b6d1b
 
 
 
 
 
3b399e8
56b6d1b
 
 
 
 
 
 
 
 
3b399e8
56b6d1b
 
 
 
 
3b399e8
 
56b6d1b
3b399e8
56b6d1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# ============================================
# DOCKERFILE FAUCET BOT - FULL FIX
# ============================================
FROM python:3.9-slim

# -------------------------------
# 1. Install system dependencies + Xvfb
# -------------------------------
RUN apt-get update && apt-get install -y \
    curl \
    wget \
    gnupg \
    ca-certificates \
    xz-utils \
    xvfb \
    fonts-liberation \
    libnss3 \
    libatk-bridge2.0-0 \
    libx11-xcb1 \
    libxcb-dri3-0 \
    libxcomposite1 \
    libxdamage1 \
    libxrandr2 \
    libgbm1 \
    libasound2 \
    libatk1.0-0 \
    libgtk-3-0 \
    libxshmfence1 \
    && rm -rf /var/lib/apt/lists/*

# -------------------------------
# 2. Install Google Chrome
# -------------------------------
RUN mkdir -p /etc/apt/keyrings \
    && wget -q -O - https://dl.google.com/linux/linux_signing_key.pub > /tmp/google.pub \
    && gpg --dearmor < /tmp/google.pub > /etc/apt/keyrings/google-chrome.gpg \
    && echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
    && apt-get update \
    && apt-get install -y google-chrome-stable \
    && rm -rf /var/lib/apt/lists/* \
    && rm /tmp/google.pub

WORKDIR /app

# -------------------------------
# 3. Install Python dependencies
# -------------------------------
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# -------------------------------
# 4. Install Node.js 20
# -------------------------------
RUN mkdir -p /etc/apt/keyrings \
    && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
    && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
    && apt-get update \
    && apt-get install -y nodejs \
    && rm -rf /var/lib/apt/lists/*

# -------------------------------
# 5. Copy API
# -------------------------------
COPY Api/ /app/Api/
WORKDIR /app/Api
RUN npm install --omit=dev

WORKDIR /app

# -------------------------------
# 6. Copy Python bot
# -------------------------------
COPY app.py .

# -------------------------------
# 7. Startup Script
# -------------------------------
RUN echo '#!/bin/bash\n\
echo "🤖 STARTING FAUCET BOT"\n\
echo "======================"\n\
\n\
echo "Starting Node.js API..."\n\
cd /app/Api\n\
node Api.js &\n\
\n\
echo "Waiting for API to start..."\n\
sleep 5\n\
\n\
echo "Starting Python Bot..."\n\
cd /app\n\
xvfb-run -a python3 app.py\n\
' > /start.sh && chmod +x /start.sh

# -------------------------------
# 8. Healthcheck
# -------------------------------
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
    CMD curl -f http://localhost:3000/ || exit 1

# -------------------------------
# 9. Expose API port
# -------------------------------
EXPOSE 3000

# -------------------------------
# 10. Start container
# -------------------------------
CMD ["/start.sh"]