-
Notifications
You must be signed in to change notification settings - Fork 2
fix: robust pdfjs-dist worker resolution + Docker deployment #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| node_modules | ||
| .pnpm-store | ||
| .next | ||
| .turbo | ||
| dist | ||
| coverage | ||
| .git | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
| *.log | ||
| *.tsbuildinfo | ||
| local-blobs | ||
| test-parse.* | ||
| e2e/test-results | ||
| e2e/report | ||
| e2e/.auth | ||
| .DS_Store | ||
| .vscode | ||
| .idea | ||
| .claude | ||
| docs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| FROM node:20-alpine AS base | ||
|
|
||
| RUN corepack enable && corepack prepare pnpm@9.15.4 --activate | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy workspace root files | ||
| COPY package.json pnpm-workspace.yaml pnpm-lock.yaml* turbo.json tsconfig.json ./ | ||
|
|
||
| # Copy all package.json files for dependency resolution | ||
| COPY apps/web/package.json apps/web/ | ||
| COPY packages/common/package.json packages/common/ | ||
| COPY packages/database/package.json packages/database/ | ||
| COPY packages/blob-storage/package.json packages/blob-storage/ | ||
| COPY packages/ai/package.json packages/ai/ | ||
| COPY packages/ingestion/package.json packages/ingestion/ | ||
| COPY packages/events/package.json packages/events/ | ||
| COPY packages/sharing/package.json packages/sharing/ | ||
|
|
||
| # Install dependencies (shamefully-hoist for Next.js bundler compatibility) | ||
| RUN echo "shamefully-hoist=true" > .npmrc && pnpm install --frozen-lockfile | ||
|
|
||
| # Copy all source | ||
| COPY packages/ packages/ | ||
| COPY apps/web/ apps/web/ | ||
|
|
||
| # Copy root .env.example as build-time .env (real values come at runtime) | ||
| COPY .env.example .env | ||
|
|
||
| # Build the Next.js app via turbo (resolves workspace deps correctly) | ||
| RUN pnpm turbo build --filter=@openvitals/web | ||
|
|
||
| # Production stage | ||
| FROM node:20-alpine AS runner | ||
| WORKDIR /app | ||
|
|
||
| ENV NODE_ENV=production | ||
| ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
|
||
| RUN addgroup --system --gid 1001 nodejs && \ | ||
| adduser --system --uid 1001 nextjs | ||
|
|
||
| # Create blob directory with correct ownership | ||
| RUN mkdir -p /data/blobs && chown nextjs:nodejs /data/blobs | ||
|
|
||
| # Copy standalone output | ||
| COPY --from=base /app/apps/web/.next/standalone ./ | ||
| COPY --from=base /app/apps/web/.next/static ./apps/web/.next/static | ||
| COPY --from=base /app/apps/web/public ./apps/web/public | ||
|
|
||
| USER nextjs | ||
|
|
||
| EXPOSE 3000 | ||
|
|
||
| ENV PORT=3000 | ||
| ENV HOSTNAME="0.0.0.0" | ||
|
|
||
| CMD ["node", "apps/web/server.js"] | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||||||||||||
| services: | ||||||||||||||||||
| postgres: | ||||||||||||||||||
| image: postgres:16-alpine | ||||||||||||||||||
| restart: unless-stopped | ||||||||||||||||||
| environment: | ||||||||||||||||||
| POSTGRES_USER: ${POSTGRES_USER:-postgres} | ||||||||||||||||||
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | ||||||||||||||||||
| POSTGRES_DB: ${POSTGRES_DB:-openvitals} | ||||||||||||||||||
| volumes: | ||||||||||||||||||
| - pgdata:/var/lib/postgresql/data | ||||||||||||||||||
| healthcheck: | ||||||||||||||||||
| test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"] | ||||||||||||||||||
| interval: 10s | ||||||||||||||||||
| timeout: 5s | ||||||||||||||||||
| retries: 5 | ||||||||||||||||||
|
|
||||||||||||||||||
| web: | ||||||||||||||||||
| build: | ||||||||||||||||||
| context: . | ||||||||||||||||||
| dockerfile: apps/web/Dockerfile | ||||||||||||||||||
| restart: unless-stopped | ||||||||||||||||||
| ports: | ||||||||||||||||||
| - "${WEB_PORT:-3000}:3000" | ||||||||||||||||||
| environment: | ||||||||||||||||||
| DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-openvitals} | ||||||||||||||||||
| BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET} | ||||||||||||||||||
| BETTER_AUTH_URL: ${BETTER_AUTH_URL:-http://localhost:3000} | ||||||||||||||||||
| NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-http://localhost:3000} | ||||||||||||||||||
|
Chocksy marked this conversation as resolved.
|
||||||||||||||||||
| OPENROUTER_API_KEY: ${OPENROUTER_API_KEY} | ||||||||||||||||||
| AI_DEFAULT_MODEL: ${AI_DEFAULT_MODEL:-google/gemini-2.5-flash} | ||||||||||||||||||
| BLOB_STORAGE_PROVIDER: local | ||||||||||||||||||
| LOCAL_BLOB_DIR: /data/blobs | ||||||||||||||||||
| RENDER_WORKER_URL: http://worker:4000 | ||||||||||||||||||
| RENDER_WEBHOOK_SECRET: ${RENDER_WEBHOOK_SECRET} | ||||||||||||||||||
| ENCRYPTION_KEY: ${ENCRYPTION_KEY} | ||||||||||||||||||
| NODE_ENV: production | ||||||||||||||||||
| volumes: | ||||||||||||||||||
| - blobdata:/data/blobs | ||||||||||||||||||
| depends_on: | ||||||||||||||||||
| postgres: | ||||||||||||||||||
| condition: service_healthy | ||||||||||||||||||
|
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Both services depend only on
Suggested change
|
||||||||||||||||||
| migrate: | ||||||||||||||||||
| condition: service_completed_successfully | ||||||||||||||||||
|
|
||||||||||||||||||
| worker: | ||||||||||||||||||
| build: | ||||||||||||||||||
| context: . | ||||||||||||||||||
| dockerfile: services/ingestion-worker/Dockerfile | ||||||||||||||||||
| restart: unless-stopped | ||||||||||||||||||
| environment: | ||||||||||||||||||
| DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-openvitals} | ||||||||||||||||||
| OPENROUTER_API_KEY: ${OPENROUTER_API_KEY} | ||||||||||||||||||
| AI_DEFAULT_MODEL: ${AI_DEFAULT_MODEL:-google/gemini-2.5-flash} | ||||||||||||||||||
| BLOB_STORAGE_PROVIDER: local | ||||||||||||||||||
| LOCAL_BLOB_DIR: /data/blobs | ||||||||||||||||||
| RENDER_WEBHOOK_SECRET: ${RENDER_WEBHOOK_SECRET} | ||||||||||||||||||
| NODE_ENV: production | ||||||||||||||||||
| volumes: | ||||||||||||||||||
| - blobdata:/data/blobs | ||||||||||||||||||
| depends_on: | ||||||||||||||||||
| postgres: | ||||||||||||||||||
| condition: service_healthy | ||||||||||||||||||
| migrate: | ||||||||||||||||||
| condition: service_completed_successfully | ||||||||||||||||||
|
|
||||||||||||||||||
| # Run migrations and seed on deploy (one-shot, exits after completion) | ||||||||||||||||||
| migrate: | ||||||||||||||||||
| build: | ||||||||||||||||||
| context: . | ||||||||||||||||||
| dockerfile: apps/web/Dockerfile | ||||||||||||||||||
| target: base | ||||||||||||||||||
| restart: "no" | ||||||||||||||||||
| environment: | ||||||||||||||||||
| DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-openvitals} | ||||||||||||||||||
| working_dir: /app | ||||||||||||||||||
| command: > | ||||||||||||||||||
| sh -c "cd packages/database && pnpm db:migrate" | ||||||||||||||||||
| depends_on: | ||||||||||||||||||
| postgres: | ||||||||||||||||||
| condition: service_healthy | ||||||||||||||||||
|
|
||||||||||||||||||
| volumes: | ||||||||||||||||||
| pgdata: | ||||||||||||||||||
| blobdata: | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output: 'standalone'not set in next.config.tsThe Dockerfile copies from
.next/standaloneand runsnode apps/web/server.js, butapps/web/next.config.tsdoes not includeoutput: 'standalone'. Without this option Next.js will not generate the standalone directory or theserver.jsentrypoint — theCOPY --from=base /app/apps/web/.next/standalone ./step copies nothing, and the container will crash on startup.Add to
apps/web/next.config.ts: