- Split `validate` into `validate-python` and `validate-frontend`; publish needs both. Runner capacity is >= 2 (publish and migrate already overlap). - deploy/ci-python-venv.sh: venv kept under /root/.cache keyed by Python version, ISO week, pins and requirements; persistent pip cache. A fresh venv per run spent ~3 min re-downloading the same wheels. - npm ci gets a persistent download cache and --prefer-offline (every one of 1,010 packages was a cache miss). - publish builds and pushes the API and web images concurrently; the web Dockerfile mounts BuildKit caches for npm and .next/cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
48 lines
2.1 KiB
Python
48 lines
2.1 KiB
Python
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_railway_services_use_the_product_frontend_and_dynamic_ports() -> None:
|
|
web = (ROOT / "deploy" / "railway-web.Dockerfile").read_text(encoding="utf-8")
|
|
api = (ROOT / "deploy" / "railway-api.Dockerfile").read_text(encoding="utf-8")
|
|
|
|
assert "COPY frontend/package.json frontend/package-lock.json" in web
|
|
assert "HOSTNAME=0.0.0.0" in web
|
|
assert 'CMD ["node", "server.js"]' in web
|
|
assert "next-env.d.ts" not in web
|
|
|
|
assert "FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/python:3.12-slim" in api
|
|
assert "daocloud" not in api.lower()
|
|
assert "PIP_INDEX_URL=https://mirrors.huaweicloud.com/repository/pypi/simple/" in api
|
|
assert "mirrors.aliyun.com" not in api
|
|
assert api.index("apt-get install -y --no-install-recommends build-essential nodejs") < api.index(
|
|
"python -m pip install -r requirements.txt"
|
|
)
|
|
assert "COPY SKILL.md mcp_server.py" in api
|
|
assert "--host 0.0.0.0" in api and "${PORT:-5200}" in api
|
|
assert "http.server" not in api
|
|
|
|
assert "FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/node:22-alpine" in web
|
|
assert "daocloud" not in web.lower()
|
|
|
|
|
|
def test_web_image_copies_postcss_config_before_building_frontend() -> None:
|
|
web = (ROOT / "deploy" / "railway-web.Dockerfile").read_text(encoding="utf-8")
|
|
config_copy = "COPY frontend/next.config.ts frontend/postcss.config.mjs frontend/tsconfig.json ./"
|
|
|
|
assert config_copy in web
|
|
# Was `RUN npm run build`; the build step now carries a BuildKit cache mount
|
|
# for .next/cache (CI speed-up), so match the command itself.
|
|
build = "target=/app/frontend/.next/cache npm run build"
|
|
assert web.index(config_copy) < web.index(build)
|
|
|
|
|
|
def test_server_compose_allows_only_the_internal_api_hostname() -> None:
|
|
compose = (ROOT / "deploy" / "docker-compose.server.yml").read_text(encoding="utf-8")
|
|
|
|
assert "JYOTISH_ALLOWED_HOSTS: localhost,127.0.0.1,::1,api" in compose
|
|
assert "api_scratch:/app/scratch/local" in compose
|
|
assert " api_scratch:" in compose
|