bot_host / Dockerfile
ItsBounvy's picture
Upload 31 files
66916b2 verified
Raw History Blame Contribute Delete
2.21 kB
# =============================================================================
# MMaxAI Hosting Panel — Docker image for HF Spaces.
#
# Build context = hosting_panel/ directory contents (uploaded directly,
# NOT the full repo). All COPY paths are relative to that context root.
#
# Works for BOTH targets:
# * HuggingFace Space: HF expects port 7860 (Render too — uses $PORT,
# so we default to 7860 if $PORT is unset).
# * Render Web Service: $PORT is set automatically by Render.
#
# Entry point: app:app (app.py exports the FastAPI instance).
# The sys.path self-patch at the top of app.py ensures bare imports
# (from config import ...) resolve regardless of CWD.
#
# Shell form (NOT JSON/exec form): some PaaS runners (Render included)
# pass the raw `CMD ["sh", "-c", "..."]` array to /bin/sh verbatim,
# which fails with `/bin/sh: 1: [sh,: not found`. Shell form avoids
# this entirely.
# =============================================================================
FROM python:3.12-slim
# System deps: curl for healthcheck, git for bot source clones,
# build-essential for any pip packages that need compiling (e.g.
# cryptography on some architectures).
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Python setup
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install panel deps first (better layer caching).
# Build context is hosting_panel/ contents, so requirements.txt is at root.
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy all panel source files into the image.
COPY . ./
# Runtime dirs.
# /app/data — SQLite DB (write-through to HF Dataset via panel-storage,
# so ephemeral disk loss on HF Spaces is recoverable).
RUN mkdir -p /app/data
# NOTE: do NOT set EXPOSE — Render assigns $PORT dynamically (default
# 10000 on the free tier). HF Space expects 7860; Render sets $PORT.
# The ${PORT:-7860} fallback handles both worlds.
CMD exec uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}