metatron-open-seo/Dockerfile.selfhost
2026-07-29 23:10:01 -04:00

33 lines
1.6 KiB
Docker

# Use the full Node image so workerd has a working CA trust store for outbound HTTPS.
FROM node:22
ENV PNPM_HOME=/pnpm
ENV PATH=$PNPM_HOME:$PATH
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@10.30.1 --activate
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
EXPOSE 3001
# Readiness probe against the unauthenticated setup/health endpoint. The long
# start period covers migrations plus the boot-time vite build below.
HEALTHCHECK --interval=30s --timeout=10s --start-period=300s --retries=3 \
CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||3001)+'/api/health').then(function(r){process.exit(r.ok?0:1)}).catch(function(){process.exit(1)})"
# The preflight validates env BEFORE the slow steps, so misconfiguration fails
# in seconds with the exact fix instead of after a multi-minute build.
#
# The build MUST run at container start, not image-build time: AUTH_MODE (and the
# other client envs) are inlined into the client bundle by `vite build`, and the
# self-hoster only chooses AUTH_MODE at runtime via Compose. Building here lets
# that runtime value bake into the bundle. The repo .npmrc raises the V8 heap
# ceiling (node-options) so the ~7400-module SSR build doesn't OOM under Node's
# ~2GB default.
CMD ["sh", "-c", "echo 'OpenSEO sends an anonymous usage heartbeat (counts only). Disable: OPENSEO_TELEMETRY_DISABLED=1. Details: docs/SELF_HOSTING_DOCKER.md#telemetry' && pnpm exec tsx scripts/selfhost-preflight.ts && pnpm run db:migrate:local && pnpm run build && pnpm exec vite preview --host 0.0.0.0 --port ${PORT:-3001}"]