File size: 1,817 Bytes
124816b 73925a5 124816b 174cc12 e836aa9 124816b 174cc12 124816b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | FROM ollama/ollama:0.40.13 AS ollama-runtime
# The backend-only target remains available for Docker Compose / Render.
FROM python:3.11-slim AS backend
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends libexpat1 libgomp1 ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ENV PYTHONUNBUFFERED=1 SATFORGE_DATA=/data SATFORGE_PIPELINE_ENABLED=1
COPY requirements.txt requirements-ai.txt ./
RUN pip install --no-cache-dir torch==2.10.0 torchvision==0.25.0 --index-url https://download.pytorch.org/whl/cpu \
&& pip install --no-cache-dir -r requirements.txt -r requirements-ai.txt
COPY backend ./backend
COPY ai ./ai
COPY scripts ./scripts
COPY data/boundaries ./data/boundaries
COPY models ./models
RUN python -c "from backend.sources import install_model; install_model()"
EXPOSE 8000
CMD ["sh", "-c", "uvicorn backend.app:app --host 0.0.0.0 --port ${PORT:-8000} --workers 1"]
# Hugging Face builds the final target: both models and API in one Docker Space.
FROM backend AS space
USER root
RUN useradd --create-home --uid 1000 sahab \
&& mkdir -p /home/sahab/data /home/sahab/ollama-models \
&& chown -R sahab:sahab /home/sahab /app
COPY --from=ollama-runtime /usr/bin/ollama /usr/bin/ollama
COPY --from=ollama-runtime /usr/lib/ollama /usr/lib/ollama
ENV PORT=7860 SATFORGE_DATA=/home/sahab/data \
OLLAMA_MODELS=/home/sahab/ollama-models OLLAMA_HOST=127.0.0.1:11434 \
OLLAMA_NO_CLOUD=1 OLLAMA_NUM_PARALLEL=1 OLLAMA_MAX_LOADED_MODELS=1 \
SATFORGE_OLLAMA_URL=http://127.0.0.1:11434 \
SATFORGE_NARRATOR_MODEL=qwen3.5:0.8b \
OMP_NUM_THREADS=2 MKL_NUM_THREADS=2
USER sahab
# Download at build time so cold starts do not download another model.
RUN python -m scripts.space_runtime --download-model
EXPOSE 7860
CMD ["python", "-m", "scripts.space_runtime"]
|