fix(agenthub): Compile migrations and expose postgres port for diagnosis
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:
parent
7ece5367a4
commit
c84de0f4f4
4 changed files with 26 additions and 6 deletions
17
Dockerfile
17
Dockerfile
|
|
@ -26,6 +26,10 @@ RUN NODE_ENV=development npm ci
|
|||
COPY tsconfig.json tsconfig.build.json ./
|
||||
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
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
|
@ -48,9 +52,16 @@ RUN apt-get update && \
|
|||
COPY --from=deps --chown=agenthub:agenthub /app/node_modules ./node_modules
|
||||
COPY --from=build --chown=agenthub:agenthub /app/dist ./dist
|
||||
COPY --chown=agenthub:agenthub package.json ./
|
||||
|
||||
# Copy Drizzle migrations (required for migration runtime)
|
||||
COPY --chown=agenthub:agenthub drizzle ./drizzle
|
||||
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
|
||||
|
||||
|
|
@ -59,5 +70,5 @@ EXPOSE 3000
|
|||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
|
||||
CMD curl -f http://127.0.0.1:3000/healthz || exit 1
|
||||
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["node", "dist/server.js"]
|
||||
# Use tini as init system for proper signal handling and run entrypoint
|
||||
ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ services:
|
|||
PGDATA: /var/lib/postgresql/data/pgdata
|
||||
volumes:
|
||||
- postgres_data_v2:/var/lib/postgresql/data
|
||||
ports:
|
||||
- '15432:5432'
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-agenthub} -d ${POSTGRES_DB:-agenthub}']
|
||||
|
|
|
|||
8
scripts/entrypoint.sh
Normal file
8
scripts/entrypoint.sh
Normal 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
|
||||
|
|
@ -2,13 +2,12 @@
|
|||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"declaration": false,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "scripts", "vitest.config.ts"]
|
||||
"include": ["src/**/*", "scripts/migrate.ts"],
|
||||
"exclude": ["node_modules", "dist", "test", "vitest.config.ts"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue