bba-telegram-bot / Dockerfile
Simzy's picture
Upload folder using huggingface_hub
24b805a verified
Raw History Blame Contribute Delete
1.01 kB
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies for yfinance/pandas
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ && \
rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY bot.py .
# HuggingFace Spaces uses port 7860 — but this bot uses long polling, not a web server.
# We need a simple health check endpoint so HF doesn't think the Space is dead.
# Create a tiny health check server that runs alongside the bot.
RUN echo 'import http.server, threading, os\nclass H(http.server.BaseHTTPRequestHandler):\n def do_GET(s):\n s.send_response(200); s.send_header("Content-Type","text/plain"); s.end_headers(); s.wfile.write(b"OK")\n def log_message(s,*a): pass\nt = threading.Thread(target=lambda: http.server.HTTPServer(("0.0.0.0",7860),H).serve_forever, daemon=True)\nt.start()\n' > /app/health.py
CMD ["python", "-c", "exec(open('health.py').read()); exec(open('bot.py').read())"]