Railyard side of PY1.3 (RYP-D2, RYP-E1, SC-E3). Acceptance:
1. apps/insights: umami-software/umami v3.4.0 (MIT, commit ec0ff503),
vendored --depth 1, LICENSE kept, NOTICE added. Fork additions only:
src/railyard/{ingest,summary,tenancy,api-only}.ts, /v1/ingest/batch (the
edge collector contract v1, bearer INSIGHTS_INGEST_TOKEN, no IP ever,
retried batches de-duplicated by migration 90_railyard_ingest_receipts),
/api/v1/tenants/{org}/summary (bearer INSIGHTS_API_TOKEN), src/proxy.ts
(INSIGHTS_API_ONLY=1 serves only the Railyard API and the heartbeat).
Tenant isolation is tested at the API level (an app id owned by another org
is refused) and at the SQL level (upstream migrations 01-26 plus 90 on a
throwaway cluster: org B never reads org A's rows, even naming its app).
Upstream vitest suite: not run on the Mac (pnpm 12.3.4 pinned upstream,
disk floor); it runs in the image build on box 2 or CI.
2. No upstream product name in anything a customer loads: the page tag, the
console pages and the fork's additions (tests); the upstream dashboard is
never served in API-only mode.
3. The console writes the collector's site entry on "Add app", on
auto-created apps from deploys, and rewrites every entry on add-on, plan or
pause changes (lib/sites.ts, SITES KV binding). The bridge gains
`sites` (the project's app, site key, page tag and collector URLs, entry
written) and the analytics proof is the first event from Insights. The
console's Insights page shows visitors, events, first event and the
visit -> signup -> first action funnel.
5. insights-edge/src/caps.ts: at 100% of the cap events are still counted and
not stored until the next UTC month; the console shows the same message
from a byte-identical copy (lib/caps.ts, tested).
4 (384 MB at 50 events a second for 10 min) is measured on staging before deploy.
Env: INSIGHTS_API_URL, INSIGHTS_API_TOKEN, SITES KV binding (console);
INSIGHTS_INGEST_TOKEN, INSIGHTS_API_TOKEN, INSIGHTS_API_ONLY (Insights).
Tests: console 54/54 (tsc clean), insights fork 7/7 (incl. SQL isolation),
insights-edge caps + collector + sim 14/14, tests/contract 3/3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
105 lines
3.7 KiB
Docker
105 lines
3.7 KiB
Docker
ARG NODE_IMAGE_VERSION="22-alpine"
|
|
ARG PNPM_VERSION="12.3.4"
|
|
# Keep in sync with the prisma/@prisma/* versions in package.json
|
|
ARG PRISMA_VERSION="7.10.0"
|
|
|
|
# Install dependencies only when needed
|
|
FROM node:${NODE_IMAGE_VERSION} AS deps
|
|
ARG PNPM_VERSION
|
|
|
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
# Workspace packages (@umami/api-client, @umami/mcp) must be present for a frozen install.
|
|
COPY packages/api-client/package.json ./packages/api-client/
|
|
COPY packages/mcp/package.json ./packages/mcp/
|
|
COPY packages/mcp/bin ./packages/mcp/bin/
|
|
RUN npm install -g pnpm@${PNPM_VERSION}
|
|
|
|
RUN printf 'strictDepBuilds: false\n' >> pnpm-workspace.yaml
|
|
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Rebuild the source code only when needed
|
|
FROM node:${NODE_IMAGE_VERSION} AS builder
|
|
ARG PNPM_VERSION
|
|
WORKDIR /app
|
|
# build:openapi shells out to pnpm, so the builder stage needs it too
|
|
RUN npm install -g pnpm@${PNPM_VERSION}
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=deps /app/packages/api-client/node_modules ./packages/api-client/node_modules
|
|
COPY --from=deps /app/packages/mcp/node_modules ./packages/mcp/node_modules
|
|
COPY . .
|
|
COPY docker/proxy.ts ./src
|
|
|
|
ARG BASE_PATH
|
|
|
|
ENV BASE_PATH=$BASE_PATH
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV DATABASE_URL="postgresql://user:pass@localhost:5432/dummy"
|
|
|
|
ARG SKIP_BUILD_GEO
|
|
ENV SKIP_BUILD_GEO=$SKIP_BUILD_GEO
|
|
|
|
RUN pnpm build:docker
|
|
|
|
# Production image, copy all the files and run next
|
|
FROM node:${NODE_IMAGE_VERSION} AS runner
|
|
WORKDIR /app
|
|
|
|
ARG NODE_OPTIONS
|
|
ARG PNPM_VERSION
|
|
ARG PRISMA_VERSION
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV NODE_OPTIONS=$NODE_OPTIONS
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
# Bootstrap pnpm with the bundled npm, then remove npm in the same layer so the
|
|
# vulnerable packages vendored inside the npm CLI are not shipped in the final
|
|
# image. pnpm is the only package manager needed at build and runtime.
|
|
RUN set -x \
|
|
&& apk add --no-cache curl libc6-compat \
|
|
&& npm install -g pnpm@${PNPM_VERSION} \
|
|
&& rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx
|
|
|
|
RUN echo {} > package.json
|
|
|
|
RUN printf "allowBuilds:\n '@prisma/engines': true\n prisma: false\nverifyDepsBeforeRun: false\n" > pnpm-workspace.yaml
|
|
|
|
# Script dependencies
|
|
RUN pnpm add npm-run-all dotenv chalk semver \
|
|
prisma@${PRISMA_VERSION} \
|
|
@prisma/client@${PRISMA_VERSION} \
|
|
@prisma/adapter-pg@${PRISMA_VERSION}
|
|
|
|
# Assert the @prisma/engines postinstall actually downloaded the engine
|
|
# binaries. If pnpm blocked the build script (e.g. allowBuilds not honored by
|
|
# the installed pnpm version), prisma would try to download engines at runtime
|
|
# as the non-root user and fail with a permissions error.
|
|
RUN ls node_modules/.pnpm/@prisma+engines@${PRISMA_VERSION}/node_modules/@prisma/engines/*engine* \
|
|
|| (echo "ERROR: Prisma engine binaries missing - @prisma/engines postinstall was blocked" && exit 1)
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
|
COPY --from=builder /app/scripts ./scripts
|
|
COPY --from=builder /app/generated ./generated
|
|
|
|
# Automatically leverage output traces to reduce image size
|
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV HOSTNAME=0.0.0.0
|
|
ENV PORT=3000
|
|
|
|
CMD ["sh", "scripts/start-docker.sh"]
|