Files
zeekay bb8982e354 Sign in on hanzo.ai, carrying this app's own request
/login drew its own card against hanzo.id: discovery and the provider
methods were read from hanzo.id, and "Continue with GitHub" went
through hanzo.id's authorize. It also could not see a person already
signed in on hanzo.ai, whose IAM session is host-only there.

A signed-out visit now stashes the page asked for and leaves for
hanzo.ai/login (/signup for a new account) with the query of the
authorize request @hanzo/iam builds for hanzo-analytics: its callback,
a fresh state and an S256 challenge whose verifier stays here.
hanzo.ai finishes it, "Continue as" or its own sign-in, and
/auth/callback exchanges the code and returns to that page.

The browser asks IAM at api.hanzo.ai only: discovery, token, refresh,
userinfo and revocation. The server reads IAM's keys there and pins
the issuer to the iss tokens name. @hanzo/iam moves to 0.21.32, and
the home org is read from the principal's org, the field it carries.

The release is revived: deploy.yml built with buildx and qemu on a
repo with Actions disabled, so nothing built. hanzo.yml and the
hanzoai/ci caller have the door build the image in-cluster. jest runs
through esbuild, since ts-jest cannot drive TypeScript 7 and every
suite failed before it ran.
2026-10-16 23:27:00 -07:00

80 lines
2.5 KiB
Docker

ARG NODE_IMAGE_VERSION="22-alpine"
# Install dependencies only when needed
FROM node:${NODE_IMAGE_VERSION} AS deps
# 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 ./
# The version package.json declares; its allowBuilds list approves the build scripts.
RUN npm install -g [email protected]
RUN pnpm install --frozen-lockfile
# Rebuild the source code only when needed
FROM node:${NODE_IMAGE_VERSION} AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
COPY docker/middleware.ts ./src
ARG BASE_PATH
ARG NEXT_PUBLIC_APP_NAME="Hanzo Analytics"
# Client-side IAM config is read in a browser bundle, so Next.js inlines these
# at build time — the runtime App CR env never reaches the browser. Where IAM is
# asked (api.hanzo.ai) and where people sign in (hanzo.ai) are src/lib/iam.ts.
ARG NEXT_PUBLIC_IAM_CLIENT_ID="hanzo-analytics"
ARG NEXT_PUBLIC_IAM_ORG="hanzo"
ENV BASE_PATH=$BASE_PATH
ENV NEXT_TELEMETRY_DISABLED=1
ENV NEXT_PUBLIC_APP_NAME=$NEXT_PUBLIC_APP_NAME
ENV NEXT_PUBLIC_IAM_CLIENT_ID=$NEXT_PUBLIC_IAM_CLIENT_ID
ENV NEXT_PUBLIC_IAM_ORG=$NEXT_PUBLIC_IAM_ORG
ENV DATABASE_URL="postgresql://user:pass@localhost:5432/dummy"
RUN npm run build-docker
# Production image, copy all the files and run next
FROM node:${NODE_IMAGE_VERSION} AS runner
WORKDIR /app
ARG PRISMA_VERSION="7.10.0"
ARG NODE_OPTIONS
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
RUN set -x \
&& apk add --no-cache curl \
&& npm install -g pnpm@9
# Script dependencies
RUN pnpm add npm-run-all dotenv chalk semver \
prisma@${PRISMA_VERSION} \
@prisma/adapter-pg@${PRISMA_VERSION} \
@prisma/client@${PRISMA_VERSION}
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/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 ["pnpm", "start-docker"]