Skip to content

Image Pipeline Playground

chore(repo): add production static serving, Dockerfile, and example graph

Mohammad Rajaeid1f5bb6c389f
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..fe8f3c0
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,19 @@
+# syntax=docker/dockerfile:1
+
+FROM node:22-alpine AS frontend-build
+WORKDIR /app/frontend
+COPY frontend/package.json frontend/package-lock.json ./
+RUN npm ci
+COPY frontend/ ./
+RUN npm run build
+
+FROM python:3.11-slim AS runtime
+WORKDIR /app
+COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
+COPY backend/ /app/backend/
+WORKDIR /app/backend
+RUN uv sync --frozen --no-dev
+COPY --from=frontend-build /app/frontend/dist /app/frontend/dist
+ENV IMAGE_PIPES_CACHE_DIR=/app/backend/cache
+EXPOSE 8000
+CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
diff --git a/backend/app/main.py b/backend/app/main.py
index dc7fb84..47c2d0c 100644
--- a/backend/app/main.py
+++ b/backend/app/main.py
@@ -33,3 +33,12 @@ app.include_router(ws_router)
@app.get("/api/health")
def health() -> dict[str, str]:
return {"status": "ok"}
+
+
+def _maybe_mount_frontend() -> None:
+ from app.services.static import mount_frontend
+
+ mount_frontend(app)
+
+
+_maybe_mount_frontend()
diff --git a/backend/app/services/static.py b/backend/app/services/static.py
new file mode 100644
index 0000000..a288a03
--- /dev/null
+++ b/backend/app/services/static.py
@@ -0,0 +1,27 @@
+"""Production helpers for serving the built React app."""
+
+from pathlib import Path
+
+from fastapi import FastAPI
+from fastapi.responses import FileResponse
+from fastapi.staticfiles import StaticFiles
+
+
+def mount_frontend(app: FastAPI, dist_dir: Path | None = None) -> None:
+ root = Path(__file__).resolve().parents[3]
+ dist = dist_dir or (root / "frontend" / "dist")
+ if not dist.exists():
+ return
+
+ assets = dist / "assets"
+ if assets.exists():
+ app.mount("/assets", StaticFiles(directory=assets), name="assets")
+
+ index = dist / "index.html"
+
+ @app.get("/{full_path:path}")
+ async def spa_fallback(full_path: str) -> FileResponse:
+ candidate = dist / full_path
+ if full_path and candidate.exists() and candidate.is_file():
+ return FileResponse(candidate)
+ return FileResponse(index)
diff --git a/backend/examples/blur_canny.json b/backend/examples/blur_canny.json
new file mode 100644
index 0000000..ab93c94
--- /dev/null
+++ b/backend/examples/blur_canny.json
@@ -0,0 +1,44 @@
+{
+ "name": "blur-and-canny",
+ "description": "Load an image, blur it, then extract Canny edges.",
+ "seed": 0,
+ "sample_count": 1,
+ "graph": {
+ "nodes": [
+ {
+ "id": "load-1",
+ "type": "load_image",
+ "params": { "path": "uploads/input.png" },
+ "position": { "x": 0, "y": 0 }
+ },
+ {
+ "id": "blur-1",
+ "type": "gaussian_blur",
+ "params": { "ksize": 5, "sigma": 0 },
+ "position": { "x": 220, "y": 0 }
+ },
+ {
+ "id": "canny-1",
+ "type": "canny",
+ "params": { "threshold1": 80, "threshold2": 160 },
+ "position": { "x": 440, "y": 0 }
+ }
+ ],
+ "edges": [
+ {
+ "id": "e1",
+ "source": "load-1",
+ "source_port": "image",
+ "target": "blur-1",
+ "target_port": "image"
+ },
+ {
+ "id": "e2",
+ "source": "blur-1",
+ "source_port": "image",
+ "target": "canny-1",
+ "target_port": "image"
+ }
+ ]
+ }
+}
diff --git a/docker-compose.yml b/docker-compose.yml
index b875ad4..be947f8 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,5 +5,6 @@ services:
- "8000:8000"
volumes:
- ./backend/cache:/app/backend/cache
+ - ./backend/uploads:/app/backend/uploads
environment:
- IMAGE_PIPES_CACHE_DIR=/app/backend/cache