Spaces:
Paused
Paused
File size: 1,011 Bytes
24b805a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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())"]
|