revert(server/docker): restore assets distribution image

This commit is contained in:
RainbowBird
2026-04-28 00:54:13 +08:00
parent 924d3e3005
commit 5d5f739eba
5 changed files with 89 additions and 60 deletions
+4 -30
View File
@@ -1,45 +1,19 @@
# Stage 1: build ui-server-auth from source so the HTML's Vite `base` and
# the server's route prefix are guaranteed to come from the SAME commit.
# Pulling a prebuilt `ghcr.io/moeru-ai/airi/ui-server-auth:latest` image
# previously let the two drift (server route changed to `/auth/`, prebuilt
# HTML still at `/_ui/server-auth/` → every asset 404 in prod).
#
# Debian slim (glibc), not alpine: the workspace pulls in `canvas` via
# jsdom→vitest. Canvas only ships prebuilt binaries for glibc, not musl;
# on alpine `prebuild-install` falls through to `node-gyp rebuild` which
# fails without `python3 make g++ cairo-dev pango-dev ...`. Slim is ~30MB
# heavier than alpine but is throwaway — only stage 2 ships.
FROM node:24-slim AS ui-build
WORKDIR /app
RUN corepack enable
COPY . .
RUN pnpm install --frozen-lockfile
RUN pnpm -F @proj-airi/ui-server-auth run build
# Stage 2: server runtime. Vite emits the UI dist into
# /app/apps/server/public/ui-server-auth via its `outDir`, so we COPY from
# that exact path in the builder. Server install can stay --ignore-scripts
# since the UI is already built and the server has no native deps that
# need postinstall.
FROM node:24-alpine
WORKDIR /app
RUN corepack enable
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json tsconfig.json ./
COPY patches/ ./patches/
COPY apps/server apps/server
COPY --from=ghcr.io/moeru-ai/airi/ui-server-auth:latest /app/airi/projects/ui/ui-server-auth apps/server/public/ui-server-auth
COPY packages/server-schema packages/server-schema
COPY packages/server-sdk-shared packages/server-sdk-shared
COPY --from=ui-build /app/apps/server/public/ui-server-auth apps/server/public/ui-server-auth
RUN pnpm install --frozen-lockfile --ignore-scripts
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
pnpm install --frozen-lockfile --ignore-scripts
RUN pnpm -F @proj-airi/server-schema run build
RUN pnpm -F @proj-airi/server-sdk-shared run build
+1 -29
View File
@@ -1,31 +1,3 @@
# Stage 1: build ui-server-auth from source so the HTML's Vite `base` and
# the server's route prefix are guaranteed to come from the SAME commit.
# Pulling a prebuilt `ghcr.io/moeru-ai/airi/ui-server-auth:latest` image
# previously let the two drift (server route changed to `/auth/`, prebuilt
# HTML still at `/_ui/server-auth/` → every asset 404 in prod).
#
# Debian slim (glibc), not alpine: the workspace pulls in `canvas` via
# jsdom→vitest. Canvas only ships prebuilt binaries for glibc, not musl;
# on alpine `prebuild-install` falls through to `node-gyp rebuild` which
# fails without `python3 make g++ cairo-dev pango-dev ...`. Slim is ~30MB
# heavier than alpine but is throwaway — only stage 2 ships.
FROM node:24-slim AS ui-build
WORKDIR /app
RUN corepack enable
COPY . .
RUN pnpm install --frozen-lockfile
RUN pnpm -F @proj-airi/ui-server-auth run build
# Stage 2: server runtime. Vite emits the UI dist into
# /app/apps/server/public/ui-server-auth via its `outDir`, so we COPY from
# that exact path in the builder. Server install can stay --ignore-scripts
# since the UI is already built and the server has no native deps that
# need postinstall.
FROM node:24-alpine
WORKDIR /app
@@ -34,10 +6,10 @@ RUN corepack enable
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json tsconfig.json ./
COPY patches/ ./patches/
COPY --from=ghcr.io/moeru-ai/airi/ui-server-auth:latest /app/airi/projects/ui/ui-server-auth apps/server/public/ui-server-auth
COPY apps/server apps/server
COPY packages/server-schema packages/server-schema
COPY packages/server-sdk-shared packages/server-sdk-shared
COPY --from=ui-build /app/apps/server/public/ui-server-auth apps/server/public/ui-server-auth
RUN pnpm install --frozen-lockfile --ignore-scripts
-1
View File
@@ -3,7 +3,6 @@ builder = "DOCKERFILE"
dockerfilePath = "/apps/server/production/railway/Dockerfile"
watchPatterns = [
"apps/server/**",
"apps/ui-server-auth/**",
"packages/**",
"pnpm-lock.yaml"
]
+4
View File
@@ -0,0 +1,4 @@
FROM scratch
WORKDIR /app/airi/projects/ui/ui-server-auth
COPY . /app/airi/projects/ui/ui-server-auth