fix(agenthub): Compile migrations and expose postgres port for diagnosis
Some checks are pending
CI / lint + typecheck + tests (push) Waiting to run
CI / docker build + push (push) Blocked by required conditions

Fixes BARAAA-64 DB migration and auth issues:

- Update tsconfig.build.json to compile scripts/migrate.ts (was excluded)
- Create entrypoint.sh to run migrations before server start
- Update Dockerfile to build migrate.ts and use migration entrypoint
- Expose postgres port 15432 temporarily for password diagnosis

This ensures tables are created before app starts and allows connecting
to postgres from host to diagnose 28P01 auth errors.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Paperclip FoundingEngineer 2026-05-02 10:40:34 +00:00
parent 7ece5367a4
commit c84de0f4f4
4 changed files with 26 additions and 6 deletions

View file

@ -26,6 +26,10 @@ RUN NODE_ENV=development npm ci
COPY tsconfig.json tsconfig.build.json ./ COPY tsconfig.json tsconfig.build.json ./
COPY src ./src COPY src ./src
# Copy migration script for compilation
COPY scripts/migrate.ts ./scripts/
# Build TypeScript to JavaScript (includes src and scripts/migrate.ts)
RUN npm run build RUN npm run build
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
@ -48,9 +52,16 @@ RUN apt-get update && \
COPY --from=deps --chown=agenthub:agenthub /app/node_modules ./node_modules COPY --from=deps --chown=agenthub:agenthub /app/node_modules ./node_modules
COPY --from=build --chown=agenthub:agenthub /app/dist ./dist COPY --from=build --chown=agenthub:agenthub /app/dist ./dist
COPY --chown=agenthub:agenthub package.json ./ COPY --chown=agenthub:agenthub package.json ./
# Copy Drizzle migrations (required for migration runtime)
COPY --chown=agenthub:agenthub drizzle ./drizzle COPY --chown=agenthub:agenthub drizzle ./drizzle
COPY --chown=agenthub:agenthub drizzle.config.ts ./ COPY --chown=agenthub:agenthub drizzle.config.ts ./
COPY --chown=agenthub:agenthub scripts ./scripts
# Copy entrypoint script
COPY --chown=agenthub:agenthub scripts/entrypoint.sh /entrypoint.sh
# Make entrypoint executable
RUN chmod +x /entrypoint.sh
USER agenthub USER agenthub
@ -59,5 +70,5 @@ EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \ HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
CMD curl -f http://127.0.0.1:3000/healthz || exit 1 CMD curl -f http://127.0.0.1:3000/healthz || exit 1
ENTRYPOINT ["/usr/bin/tini", "--"] # Use tini as init system for proper signal handling and run entrypoint
CMD ["node", "dist/server.js"] ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint.sh"]

View file

@ -56,6 +56,8 @@ services:
PGDATA: /var/lib/postgresql/data/pgdata PGDATA: /var/lib/postgresql/data/pgdata
volumes: volumes:
- postgres_data_v2:/var/lib/postgresql/data - postgres_data_v2:/var/lib/postgresql/data
ports:
- '15432:5432'
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-agenthub} -d ${POSTGRES_DB:-agenthub}'] test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-agenthub} -d ${POSTGRES_DB:-agenthub}']

8
scripts/entrypoint.sh Normal file
View file

@ -0,0 +1,8 @@
#!/bin/sh
set -e
echo "[entrypoint] Running database migrations..."
node dist/scripts/migrate.js
echo "[entrypoint] Starting application server..."
exec node dist/server.js

View file

@ -2,13 +2,12 @@
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"noEmit": false, "noEmit": false,
"rootDir": "src",
"outDir": "dist", "outDir": "dist",
"module": "ESNext", "module": "ESNext",
"moduleResolution": "Bundler", "moduleResolution": "Bundler",
"declaration": false, "declaration": false,
"sourceMap": true "sourceMap": true
}, },
"include": ["src/**/*"], "include": ["src/**/*", "scripts/migrate.ts"],
"exclude": ["node_modules", "dist", "test", "scripts", "vitest.config.ts"] "exclude": ["node_modules", "dist", "test", "vitest.config.ts"]
} }