fix: force recreate postgres with pgvector before app startup in deploy pipeline
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 5s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 5s
This commit is contained in:
@@ -124,12 +124,35 @@ jobs:
|
|||||||
git fetch origin main
|
git fetch origin main
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
|
|
||||||
echo "=== Building ==="
|
echo "=== Pull & recreate postgres with pgvector ==="
|
||||||
docker compose pull postgres
|
docker compose pull postgres
|
||||||
|
docker compose up -d --force-recreate postgres
|
||||||
|
|
||||||
|
echo "=== Waiting for postgres healthy ==="
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
if docker compose exec -T postgres pg_isready -U "${POSTGRES_USER:-memento}" >/dev/null 2>&1; then
|
||||||
|
echo "Postgres healthy after $((i * 2))s"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ "$i" -eq 30 ]; then
|
||||||
|
echo "ERROR: Postgres not healthy after 60s"
|
||||||
|
docker compose logs postgres --tail=30
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "=== Create vector extension ==="
|
||||||
|
docker compose exec -T postgres psql -U "${POSTGRES_USER:-memento}" -d "${POSTGRES_DB:-memento}" -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
||||||
|
|
||||||
|
echo "=== Resolve failed prisma migrations ==="
|
||||||
|
docker compose exec -T postgres psql -U "${POSTGRES_USER:-memento}" -d "${POSTGRES_DB:-memento}" -c "UPDATE \"_prisma_migrations\" SET \"finished_at\"=NOW(), \"rolled_back_at\"=NULL WHERE \"finished_at\" IS NULL AND \"rolled_back_at\" IS NULL;" || true
|
||||||
|
|
||||||
|
echo "=== Building app images ==="
|
||||||
docker compose build memento-note
|
docker compose build memento-note
|
||||||
docker compose build mcp-server
|
docker compose build mcp-server
|
||||||
|
|
||||||
echo "=== Starting ==="
|
echo "=== Starting app containers ==="
|
||||||
docker compose up -d --remove-orphans
|
docker compose up -d --remove-orphans
|
||||||
docker compose ps
|
docker compose ps
|
||||||
ENDSSH
|
ENDSSH
|
||||||
|
|||||||
44
DEPLOY-ISSUES-2.md
Normal file
44
DEPLOY-ISSUES-2.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Deployment Still Failing — 502 Error
|
||||||
|
|
||||||
|
## Date: 2026-05-12 (second attempt)
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
After push of dc4244f, deploy relaunched BUT:
|
||||||
|
- postgres container was NOT recreated with new pgvector/pgvector:pg16 image
|
||||||
|
- Still running postgres:16-alpine — no pgvector — type "vector" does not exist
|
||||||
|
- docker compose pull postgres added in deploy.yaml is not enough — need docker compose up -d --force-recreate postgres
|
||||||
|
|
||||||
|
## Production logs (192.168.1.190)
|
||||||
|
- memento-web: Restarting loop
|
||||||
|
- memento-postgres: healthy but STILL on postgres:16-alpine
|
||||||
|
- Error: type "vector" does not exist
|
||||||
|
|
||||||
|
## Root cause
|
||||||
|
deploy.yaml does docker compose build then docker compose up -d BUT:
|
||||||
|
- postgres has no build: directive — uses image directly
|
||||||
|
- docker compose up -d does NOT recreate container if image didnt change locally
|
||||||
|
- Even with docker compose pull, existing container may not be recreated
|
||||||
|
|
||||||
|
## What must be fixed
|
||||||
|
|
||||||
|
### 1. deploy.yaml (.gitea/workflows/deploy.yaml)
|
||||||
|
Add BEFORE docker compose up -d:
|
||||||
|
- docker compose pull postgres
|
||||||
|
- docker compose up -d --force-recreate postgres
|
||||||
|
- Wait for postgres healthy before continuing
|
||||||
|
Or use: docker compose up -d --force-recreate --build
|
||||||
|
|
||||||
|
### 2. Verify docker-compose.yml has correct image
|
||||||
|
image: pgvector/pgvector:pg16
|
||||||
|
|
||||||
|
### 3. Prisma migration is stuck
|
||||||
|
Old migration 20260512120000_pgvector_and_fts_search marked as failed in _prisma_migrations.
|
||||||
|
Need to mark it resolved after pgvector is installed.
|
||||||
|
|
||||||
|
### 4. Correct deployment order
|
||||||
|
1. Pull + recreate postgres with pgvector
|
||||||
|
2. Wait postgres healthy
|
||||||
|
3. Create vector extension: CREATE EXTENSION IF NOT EXISTS vector
|
||||||
|
4. Resolve failed migration in _prisma_migrations
|
||||||
|
5. Start memento-web (will run migration)
|
||||||
|
6. Start mcp-server
|
||||||
Reference in New Issue
Block a user