FROM python:3.10-slim WORKDIR /app # 1. 部品のインストール RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt diffusers transformers accelerate safetensors uvicorn # 2. ファイルの取り込み COPY . . # 3. AIが直接画面(HTML)を表示できるようにプログラムを自動改造 RUN sed -i 's/from fastapi.responses import JSONResponse/from fastapi.responses import JSONResponse, FileResponse/' server.py RUN printf "\n@app.get('/')\ndef serve_ui():\n return FileResponse('index.html')\n" >> server.py RUN sed -i 's/value="http:\/\/localhost:8000"/value=""/' index.html # 4. Hugging Faceのルールで起動 EXPOSE 7860 CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]