Fix local Docker startup for workflow app

This commit is contained in:
2026-03-21 13:03:05 -04:00
parent 249131ec00
commit 7d2816e3c4
6 changed files with 75 additions and 57 deletions

View File

@@ -17,24 +17,47 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
FROM deps AS builder
ARG NEXT_PUBLIC_API_URL=
ARG DATABASE_URL=file:data/fiscal.sqlite
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
ENV DATABASE_URL=${DATABASE_URL}
ENV DATABASE_URL=file:/tmp/fiscal-build.sqlite
ENV BETTER_AUTH_SECRET=fiscal-docker-build-secret-fiscal-docker-build-secret
ENV BETTER_AUTH_BASE_URL=http://127.0.0.1:3000
ENV BETTER_AUTH_TRUSTED_ORIGINS=http://127.0.0.1:3000,http://localhost:3000
ENV NEXT_TELEMETRY_DISABLED=1
ENV WORKFLOW_TARGET_WORLD=@workflow/world-postgres
ENV WORKFLOW_LOCAL_DATA_DIR=/app/.workflow-data
ENV RUN_WORKFLOW_SETUP_ON_START=true
ENV RUN_DB_MIGRATIONS_ON_START=true
COPY . .
ENV SKIP_NEXT_TYPECHECK_ON_BUILD=true
ENV NEXT_BUILD_CPUS=1
ENV WORKFLOW_TARGET_WORLD=local
ENV WORKFLOW_LOCAL_DATA_DIR=/tmp/.workflow-data
ENV RUN_WORKFLOW_SETUP_ON_START=false
ENV RUN_DB_MIGRATIONS_ON_START=false
# Force the Rust sidecar build to complete before the Next.js build starts.
# BuildKit otherwise runs these independent stages in parallel and can OOM locally.
COPY --from=rust-builder /app/bin/fiscal-xbrl /tmp/fiscal-xbrl
COPY next.config.js tsconfig.json postcss.config.js tailwind.config.js drizzle.config.ts instrumentation.ts next-env.d.ts ./
COPY app ./app
COPY components ./components
COPY contracts ./contracts
COPY drizzle ./drizzle
COPY hooks ./hooks
COPY lib ./lib
COPY rust ./rust
COPY scripts ./scripts
RUN --mount=type=cache,target=/app/.next/cache \
mkdir -p public /app/.workflow-data && bun run build
mkdir -p data public /tmp/.workflow-data /app/.output \
&& rm -f /tmp/fiscal-xbrl \
&& bun run generate \
&& bun --smol --bun next build --turbopack \
&& bun build --target=bun --outfile /app/.output/bootstrap-production.js scripts/bootstrap-production.ts
FROM oven/bun:1.3.5-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV HOSTNAME=0.0.0.0
ARG NEXT_PUBLIC_API_URL=
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
ENV DATABASE_URL=file:/app/data/fiscal.sqlite
ENV NEXT_TELEMETRY_DISABLED=1
ENV WORKFLOW_TARGET_WORLD=@workflow/world-postgres
ENV WORKFLOW_LOCAL_DATA_DIR=/app/.workflow-data
@@ -44,15 +67,10 @@ ENV RUN_DB_MIGRATIONS_ON_START=true
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/.output/bootstrap-production.js ./bootstrap-production.js
COPY --from=builder /app/drizzle ./drizzle
COPY --from=builder /app/scripts ./scripts
COPY --from=builder /app/lib ./lib
COPY --from=builder /app/contracts ./contracts
COPY --from=builder /app/rust/taxonomy ./rust/taxonomy
COPY --from=builder /app/tsconfig.json ./tsconfig.json
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/package.json ./package.json
COPY --from=deps /app/bun.lock ./bun.lock
COPY --from=deps /app/node_modules/@workflow/world-postgres/src/drizzle/migrations ./workflow-migrations
COPY --from=rust-builder /app/bin/fiscal-xbrl ./bin/fiscal-xbrl
RUN mkdir -p /app/data /app/.workflow-data /app/bin /app/.cache/xbrl && chmod +x /app/bin/fiscal-xbrl
@@ -63,5 +81,6 @@ ENV PORT=3000
ENV FISCAL_XBRL_BIN=/app/bin/fiscal-xbrl
ENV FISCAL_XBRL_CACHE_DIR=/app/.cache/xbrl
ENV XBRL_ENGINE_TIMEOUT_MS=45000
ENV WORKFLOW_MIGRATIONS_DIR=/app/workflow-migrations
CMD ["sh", "-c", "if [ ! -x \"${FISCAL_XBRL_BIN:-/app/bin/fiscal-xbrl}\" ]; then echo \"Missing Rust XBRL sidecar at ${FISCAL_XBRL_BIN:-/app/bin/fiscal-xbrl}\" >&2; exit 1; fi; bun run bootstrap:prod && bun server.js"]
CMD ["sh", "-c", "if [ ! -x \"${FISCAL_XBRL_BIN:-/app/bin/fiscal-xbrl}\" ]; then echo \"Missing Rust XBRL sidecar at ${FISCAL_XBRL_BIN:-/app/bin/fiscal-xbrl}\" >&2; exit 1; fi; bun /app/bootstrap-production.js && exec bun /app/server.js"]