Spaces:
Sleeping
Sleeping
Download Dockerfile from Harshilforworks/Forcast: direct link, hf CLI and curl.
- Browser
- Download file 3.28 kB
-
https://huggingface.co/spaces/Harshilforworks/Forcast/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Harshilforworks/Forcast/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Harshilforworks/Forcast/resolve/main/Dockerfile
3.28 kB
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Dockerfile β Flash Flood Risk API | |
| # | |
| # Targets Hugging Face Spaces (Docker SDK, port 7860). | |
| # Uses CPU-only PyTorch to keep the image small (~1 GB vs ~5 GB for CUDA). | |
| # | |
| # Build & run locally: | |
| # docker build -t flood-api . | |
| # docker run -p 7860:7860 flood-api | |
| # | |
| # Then open: http://localhost:7860/docs | |
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM python:3.11-slim | |
| # ββ System metadata ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| LABEL maintainer="NMIMS Hack Team" | |
| LABEL description="Flash Flood Risk Inference API β FastAPI + LSTM" | |
| WORKDIR /app | |
| # ββ Install CPU-only PyTorch FIRST βββββββββββββββββββββββββββββββββββββββββββββ | |
| # The default PyPI torch wheel bundles CUDA (~2.5 GB). | |
| # The official CPU wheel from pytorch.org is ~220 MB. | |
| RUN pip install --no-cache-dir \ | |
| "torch==2.6.0" \ | |
| --index-url https://download.pytorch.org/whl/cpu | |
| # ββ Install remaining serving dependencies βββββββββββββββββββββββββββββββββββββ | |
| # Copy only the slim requirements file (not the full training requirements.txt) | |
| COPY requirements-serve.txt . | |
| RUN pip install --no-cache-dir -r requirements-serve.txt | |
| # ββ Copy application source βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY src/ src/ | |
| COPY configs/ configs/ | |
| # ββ Copy model artifacts ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # scaler.joblib β StandardScaler fitted on training data | |
| COPY artifacts/scaler.joblib artifacts/scaler.joblib | |
| # best.pt β nowcast model (used by /predict) | |
| # forecast_24h.pt β 24h forecast model (used by /forecast) | |
| COPY models/best.pt models/best.pt | |
| COPY models/forecast_24h.pt models/forecast_24h.pt | |
| # ββ Hugging Face Spaces expects port 7860 ββββββββββββββββββββββββββββββββββββββ | |
| EXPOSE 7860 | |
| # ββ Run ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # --host 0.0.0.0 β accept connections from outside the container | |
| # --port 7860 β HF Spaces default; override with -e PORT=xxxx if needed | |
| CMD ["uvicorn", "src.api.app:app", "--host", "0.0.0.0", "--port", "7860"] | |