ff508eeaba
The api-server docker build failed on the Mac with:
ERROR: Could not resolve "../../../../version.json"
src/routes/system.ts:4
`version.json` lives at the repo root and is tracked in git, but
`docker/api-server.Dockerfile` never copied it into the `build` stage,
so esbuild (running in /app/artifacts/api-server) couldn't resolve the
`../../../../version.json` import added by commit cb894f7b.
Fix: added `COPY version.json ./` in the build stage, right after the
tsconfig copy and before `lib`/`scripts`/`artifacts` are copied. No
runtime change is needed — esbuild inlines the JSON into the bundle
via the `with { type: "json" }` import attribute, so the runtime stage
does not need the file on disk.
Local dev (`pnpm --filter @workspace/api-server run dev`) is
unaffected because it builds outside Docker against the real repo
root. tx-os Dockerfile not touched.
Mac side after pulling this commit:
cd ~/Downloads/TX && git pull && docker compose up -d --build api
59 lines
2.1 KiB
Docker
59 lines
2.1 KiB
Docker
FROM node:24-bookworm-slim AS base
|
|
ENV PNPM_HOME=/pnpm
|
|
ENV PATH=$PNPM_HOME:$PATH
|
|
RUN corepack enable && corepack prepare pnpm@10.26.1 --activate
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
chromium \
|
|
fonts-noto \
|
|
fonts-noto-color-emoji \
|
|
fonts-noto-cjk \
|
|
ca-certificates \
|
|
curl \
|
|
tini \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
|
|
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
|
|
|
WORKDIR /app
|
|
|
|
FROM base AS deps
|
|
COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./
|
|
COPY artifacts/api-server/package.json artifacts/api-server/
|
|
COPY artifacts/tx-os/package.json artifacts/tx-os/
|
|
COPY lib/api-client-react/package.json lib/api-client-react/
|
|
COPY lib/api-spec/package.json lib/api-spec/
|
|
COPY lib/api-zod/package.json lib/api-zod/
|
|
COPY lib/db/package.json lib/db/
|
|
COPY lib/object-storage-web/package.json lib/object-storage-web/
|
|
COPY scripts/package.json scripts/
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
|
pnpm install --frozen-lockfile --ignore-scripts
|
|
|
|
FROM deps AS build
|
|
COPY tsconfig.base.json* tsconfig.json* ./
|
|
COPY version.json ./
|
|
COPY lib lib
|
|
COPY scripts scripts
|
|
COPY artifacts/api-server artifacts/api-server
|
|
RUN pnpm --filter @workspace/api-server run build
|
|
|
|
FROM base AS runtime
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
COPY --from=build /app/node_modules ./node_modules
|
|
COPY --from=build /app/pnpm-workspace.yaml /app/pnpm-lock.yaml /app/package.json ./
|
|
COPY --from=build /app/lib ./lib
|
|
COPY --from=build /app/scripts ./scripts
|
|
COPY --from=build /app/artifacts/api-server/package.json ./artifacts/api-server/package.json
|
|
COPY --from=build /app/artifacts/api-server/dist ./artifacts/api-server/dist
|
|
COPY --from=build /app/artifacts/api-server/assets ./artifacts/api-server/assets
|
|
COPY --from=build /app/artifacts/api-server/node_modules ./artifacts/api-server/node_modules
|
|
COPY docker/migrate.sh /usr/local/bin/migrate.sh
|
|
RUN chmod +x /usr/local/bin/migrate.sh
|
|
RUN mkdir -p /app/storage && chown -R node:node /app/storage
|
|
USER node
|
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
|
CMD ["node", "--enable-source-maps", "/app/artifacts/api-server/dist/index.mjs"]
|