Skip to content

Commit 7139b36

Browse files
committed
fix api server frontend
1 parent f09e1eb commit 7139b36

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

images/api/Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,23 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3232
curl \
3333
&& rm -rf /var/lib/apt/lists/*
3434

35-
# ── Python dependencies ─────────────────────────────────────────────
35+
# ── Python dependencies + SPA install ───────────────────────────────
3636
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
3737

3838
WORKDIR /opt/surogates
3939
COPY pyproject.toml ./
4040
COPY surogates/ ./surogates/
4141

42+
# Place the built SPA inside the package tree *before* installing, so
43+
# setuptools bundles it into site-packages via package-data (declared
44+
# in pyproject.toml). That way ``setup_frontend()`` finds it at
45+
# Path(__file__).parent.parent / "web" / "dist" regardless of cwd.
46+
COPY --from=web-build /build/dist ./surogates/web/dist
47+
4248
RUN uv venv /opt/venv \
4349
&& uv pip install --python /opt/venv/bin/python . \
4450
&& uv pip install --python /opt/venv/bin/python uvloop
4551

46-
# ── Web SPA ──────────────────────────────────────────────────────────
47-
# Bundled alongside the python package so create_app() can resolve it
48-
# via Path(__file__).parent.parent / "web" / "dist".
49-
COPY --from=web-build /build/dist /opt/surogates/surogates/web/dist
50-
5152
ENV PATH="/opt/venv/bin:$PATH" \
5253
PYTHONUNBUFFERED=1 \
5354
PYTHONDONTWRITEBYTECODE=1

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ build-backend = "setuptools.build_meta"
5454
[tool.setuptools.packages.find]
5555
include = ["surogates*"]
5656

57+
[tool.setuptools.package-data]
58+
# Bundle the built web SPA so the API image can serve it from the
59+
# installed package location (site-packages/surogates/web/dist).
60+
surogates = ["web/dist/**/*"]
61+
5762
[tool.setuptools_scm]
5863
fallback_version = "0.0.0"
5964

0 commit comments

Comments
 (0)