Files
Jyotisha/deploy/railway-web.Dockerfile
T
ClaudeandClaude Opus 5.5 a84ebff6e4
Independent Staging Quality Gate / validate-python (push) Successful in 17m4s
Independent Staging Quality Gate / validate-frontend (push) Successful in 23m50s
Independent Staging Quality Gate / publish (push) Successful in 5m38s
ci: run the Python and frontend gates in parallel and keep install caches on the runner
- 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
2026-11-03 16:59:57 +08:00

66 lines
2.9 KiB
Docker

FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/node:22-alpine AS build
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json ./
# Same registry as the quality gate's own install: the build host times out on
# registry.npmjs.org (BUG-1503). The lock file pins every version and integrity
# hash, so the installed packages are identical.
ARG NPM_CONFIG_REGISTRY=https://registry.npmmirror.com
# The download cache outlives this layer, so a lock-file change re-downloads
# only what changed. Nothing from the cache mount ends up in the image.
RUN --mount=type=cache,id=jyotisha-web-npm,target=/root/.npm npm ci --prefer-offline
COPY frontend/src ./src
COPY frontend/public ./public
# 印度占星知识 Markdown (issue #157); read by `next build`, which prerenders /learn.
COPY frontend/content ./content
COPY frontend/next.config.ts frontend/postcss.config.mjs frontend/tsconfig.json ./
COPY frontend/scripts ./scripts
COPY frontend/db ./db
COPY frontend/supabase/migrations ./supabase/migrations
ARG NEXT_DEPLOYMENT_ID
ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
ENV NEXT_DEPLOYMENT_ID=${NEXT_DEPLOYMENT_ID} \
NEXT_PUBLIC_GIT_COMMIT=${NEXT_DEPLOYMENT_ID} \
NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL} \
NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}
COPY SKILL.md /app/SKILL.md
COPY assets /app/assets
COPY references /app/references
COPY scripts /app/scripts
COPY skills /app/skills
# Next.js build cache (webpack/SWC) across builds on the runner; it only
# speeds up compilation and never lands in the image.
RUN --mount=type=cache,id=jyotisha-web-next,target=/app/frontend/.next/cache npm run build
# File tracing pulls skills/ into the standalone bundle with symlinks resolved into
# real directories, which then collides with the explicit COPY in the final stage.
RUN rm -rf /app/frontend/.next/standalone/skills
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/node:22-alpine
WORKDIR /app/frontend
COPY --from=build /app/frontend/.next/standalone /app
COPY --from=build /app/frontend/.next/static /app/frontend/.next/static
COPY --from=build /app/frontend/public /app/frontend/public
COPY --from=build /app/frontend/db /app/frontend/db
COPY --from=build /app/frontend/supabase/migrations /app/frontend/supabase/migrations
# Live consult skill entries are git-tracked relative symlinks into /app.
COPY --from=build /app/SKILL.md /app/SKILL.md
COPY --from=build /app/assets /app/assets
COPY --from=build /app/references /app/references
COPY --from=build /app/scripts /app/scripts
COPY --from=build /app/skills /app/skills
ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
ENV NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL} \
NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}
ENV NODE_ENV=production \
HOSTNAME=0.0.0.0 \
JYOTISHA_PROJECT_ROOT=/app
CMD ["node", "server.js"]