-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (59 loc) · 2.47 KB
/
Copy pathDockerfile
File metadata and controls
74 lines (59 loc) · 2.47 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Multi-stage Dockerfile for ClimateVision
# Builds the React frontend, then packages the FastAPI backend + static files.
# -----------------------------------------------------------------------------
# Stage 1: Build the frontend
# -----------------------------------------------------------------------------
FROM node:20-slim AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
ENV VITE_API_BASE_URL=
# Google Maps browser key is baked in at build time (Vite inlines import.meta.env).
ARG VITE_GOOGLE_MAPS_API_KEY=
ENV VITE_GOOGLE_MAPS_API_KEY=$VITE_GOOGLE_MAPS_API_KEY
RUN npm run build
# -----------------------------------------------------------------------------
# Stage 2: Python API runtime
# -----------------------------------------------------------------------------
FROM python:3.11-slim AS api
WORKDIR /app
# Prevent Python from writing pyc files and buffering stdout
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV OMP_NUM_THREADS=1
# Install system dependencies required by rasterio, opencv, and other geospatial libs.
# build-essential and python3-dev are needed to compile packages like stringzilla
# that do not provide pre-built wheels for this platform.
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 \
libglib2.0-0 \
libgdal-dev \
build-essential \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt ./
# Install CPU-only PyTorch first: the default CUDA wheels unpack to >8GB,
# exceeding Fly.io's maximum uncompressed image size. The Fly VM has no GPU.
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir -r requirements.txt
# Install the ClimateVision package
COPY setup.py README.md ./
COPY src/ ./src/
RUN pip install --no-cache-dir -e .
# Copy built frontend from the first stage
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Copy config, models, and utility scripts
COPY config.yaml ./
COPY config/ ./config/
COPY models/ ./models/
COPY scripts/ ./scripts/
RUN chmod +x scripts/*.sh
# Create writable directories for SQLite and outputs
RUN mkdir -p /app/outputs /app/data /app/logs
EXPOSE 8000
# Note: GEE credentials and other secrets are supplied at runtime via env vars.
# Do not bake credentials into the image.
# The default CMD uses port 8000; Render overrides this via the PORT env var.
CMD ["./scripts/render_entrypoint.sh"]