Spaces:
Sleeping
Sleeping
| # Hugging Face Spaces (Docker) で FastAPI を動かす最小構成 | |
| FROM python:3.11-slim | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| # ← PyTensor のコンパイルキャッシュ先を /tmp に固定(permissions 対策) | |
| PYTENSOR_FLAGS="base_compiledir=/tmp/.pytensor" \ | |
| XDG_CACHE_HOME="/tmp/.cache" | |
| # PyMC / SciPy 系の実行に必要なツールとBLAS/LAPACK | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| gfortran \ | |
| libopenblas-dev \ | |
| liblapack-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # 依存インストール | |
| COPY requirements.txt /app/ | |
| RUN python -m pip install --upgrade pip setuptools wheel && \ | |
| pip install -r requirements.txt | |
| # アプリ本体 | |
| COPY . /app | |
| # キャッシュ/一時領域の作成(保険) | |
| RUN mkdir -p /tmp/.pytensor /tmp/.cache /tmp/adcopy_data && \ | |
| chmod -R 777 /tmp/.pytensor /tmp/.cache /tmp/adcopy_data || true | |
| # HF Spaces 既定ポート | |
| EXPOSE 7860 | |
| # 起動 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |