Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +57 -90
Dockerfile
CHANGED
|
@@ -1,92 +1,59 @@
|
|
| 1 |
-
FROM
|
| 2 |
-
|
| 3 |
-
# Install
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
# Set
|
| 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 |
-
}\n\
|
| 58 |
-
\n\
|
| 59 |
-
app.get('/', (req, res) => res.json({ status: 'running', connected: isConnected, endpoints: { status: 'GET /status', qr: 'GET /qr', send: 'POST /send' } }));\n\
|
| 60 |
-
app.get('/status', (req, res) => res.json({ connected: isConnected, hasQR: qrCode !== null }));\n\
|
| 61 |
-
app.get('/qr', (req, res) => {\n\
|
| 62 |
-
if (qrCode) res.json({ success: true, qr: qrCode });\n\
|
| 63 |
-
else if (isConnected) res.json({ success: false, message: 'Already connected' });\n\
|
| 64 |
-
else res.json({ success: false, message: 'QR not available yet' });\n\
|
| 65 |
-
});\n\
|
| 66 |
-
app.post('/send', async (req, res) => {\n\
|
| 67 |
-
if (!isConnected || !sock) return res.status(400).json({ success: false, message: 'Not connected' });\n\
|
| 68 |
-
const { number, message } = req.body;\n\
|
| 69 |
-
if (!number || !message) return res.status(400).json({ success: false, message: 'number and message required' });\n\
|
| 70 |
-
try {\n\
|
| 71 |
-
const jid = number.includes('@') ? number : \`\${number}@s.whatsapp.net\`;\n\
|
| 72 |
-
await sock.sendMessage(jid, { text: message });\n\
|
| 73 |
-
res.json({ success: true, message: 'Sent successfully' });\n\
|
| 74 |
-
} catch (error) {\n\
|
| 75 |
-
res.status(500).json({ success: false, message: error.message });\n\
|
| 76 |
-
}\n\
|
| 77 |
-
});\n\
|
| 78 |
-
\n\
|
| 79 |
-
const PORT = process.env.PORT || 7860;\n\
|
| 80 |
-
app.listen(PORT, '0.0.0.0', () => {\n\
|
| 81 |
-
console.log(\`🚀 Server running on port \${PORT}\`);\n\
|
| 82 |
-
connectToWhatsApp();\n\
|
| 83 |
-
});" > server.js
|
| 84 |
-
|
| 85 |
-
# Create auth directory
|
| 86 |
-
RUN mkdir -p auth_info
|
| 87 |
-
|
| 88 |
-
# Expose port
|
| 89 |
EXPOSE 7860
|
| 90 |
|
| 91 |
-
#
|
| 92 |
-
CMD ["node", "server.js"]
|
|
|
|
| 1 |
+
FROM devlikeapro/waha:latest
|
| 2 |
+
|
| 3 |
+
# Install additional dependencies for Hugging Face Spaces
|
| 4 |
+
USER root
|
| 5 |
+
|
| 6 |
+
# Set up Chrome/Chromium dependencies and network tools
|
| 7 |
+
RUN apt-get update && apt-get install -y \
|
| 8 |
+
fonts-liberation \
|
| 9 |
+
libasound2 \
|
| 10 |
+
libatk-bridge2.0-0 \
|
| 11 |
+
libatk1.0-0 \
|
| 12 |
+
libatspi2.0-0 \
|
| 13 |
+
libcups2 \
|
| 14 |
+
libdbus-1-3 \
|
| 15 |
+
libdrm2 \
|
| 16 |
+
libgbm1 \
|
| 17 |
+
libgtk-3-0 \
|
| 18 |
+
libnspr4 \
|
| 19 |
+
libnss3 \
|
| 20 |
+
libwayland-client0 \
|
| 21 |
+
libxcomposite1 \
|
| 22 |
+
libxdamage1 \
|
| 23 |
+
libxfixes3 \
|
| 24 |
+
libxkbcommon0 \
|
| 25 |
+
libxrandr2 \
|
| 26 |
+
xdg-utils \
|
| 27 |
+
dnsutils \
|
| 28 |
+
iputils-ping \
|
| 29 |
+
ca-certificates \
|
| 30 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 31 |
+
|
| 32 |
+
# Update CA certificates
|
| 33 |
+
RUN update-ca-certificates
|
| 34 |
+
|
| 35 |
+
# Hugging Face Spaces specific configurations
|
| 36 |
+
ENV WAHA_LOG_LEVEL=debug
|
| 37 |
+
ENV WHATSAPP_API_PORT=7860
|
| 38 |
+
ENV WHATSAPP_API_HOSTNAME=0.0.0.0
|
| 39 |
+
|
| 40 |
+
# Chrome/Puppeteer configurations for containerized environment
|
| 41 |
+
ENV CHROME_BIN=/usr/bin/chromium
|
| 42 |
+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
| 43 |
+
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
| 44 |
+
|
| 45 |
+
# Disable Chrome sandbox and configure for container networking
|
| 46 |
+
ENV CHROME_ARGS="--no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage --disable-gpu --disable-software-rasterizer --disable-dev-tools --no-zygote"
|
| 47 |
+
|
| 48 |
+
# DNS configuration
|
| 49 |
+
ENV NODE_OPTIONS="--dns-result-order=ipv4first"
|
| 50 |
+
|
| 51 |
+
# Create directory for sessions persistence
|
| 52 |
+
RUN mkdir -p /app/.sessions && chown -R node:node /app/.sessions
|
| 53 |
+
|
| 54 |
+
USER node
|
| 55 |
+
|
| 56 |
+
# Expose port 7860 (required by Hugging Face Spaces)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
EXPOSE 7860
|
| 58 |
|
| 59 |
+
# The base image already has the entrypoint configured
|
|
|