Add vehicle ETL import to GitLab CI deployment

This commit is contained in:
Eric Gullickson
2025-12-19 14:14:05 -06:00
parent 0e85cf48c3
commit 2174a1b1e3
5 changed files with 105875 additions and 2807 deletions

View File

@@ -73,20 +73,30 @@ deploy:
- echo "Deploying MotoVaultPro..."
- echo "=========================================="
- cd "$DEPLOY_PATH"
- echo "Step 1/6 Injecting secrets..."
- echo "Step 1/7 Injecting secrets..."
- chmod +x scripts/inject-secrets.sh
- ./scripts/inject-secrets.sh
- echo "Step 2/6 Stopping existing services..."
- echo "Step 2/7 Stopping existing services..."
- docker compose -f $DOCKER_COMPOSE_FILE -f $DOCKER_COMPOSE_PROD_FILE down --timeout 30 || true
- echo "Step 3/6 Pulling base images..."
- echo "Step 3/7 Pulling base images..."
- docker compose -f $DOCKER_COMPOSE_FILE pull
- echo "Step 4/6 Starting database services..."
- echo "Step 4/7 Starting database services..."
- docker compose -f $DOCKER_COMPOSE_FILE -f $DOCKER_COMPOSE_PROD_FILE up -d mvp-postgres mvp-redis
- echo "Waiting for database to be ready..."
- sleep 15
- echo "Step 5/6 Running database migrations..."
- echo "Step 5/7 Running database migrations..."
- docker compose -f $DOCKER_COMPOSE_FILE run --rm mvp-backend npm run migrate || echo "Migration skipped"
- echo "Step 6/6 Starting all services..."
- echo "Step 6/7 Running vehicle ETL import..."
- |
docker exec -i mvp-postgres psql -U postgres -d motovaultpro < data/vehicle-etl/migrations/001_create_vehicle_database.sql
docker exec -i mvp-postgres psql -U postgres -d motovaultpro -c "TRUNCATE TABLE vehicle_options RESTART IDENTITY CASCADE; TRUNCATE TABLE engines RESTART IDENTITY CASCADE; TRUNCATE TABLE transmissions RESTART IDENTITY CASCADE;"
docker exec -i mvp-postgres psql -U postgres -d motovaultpro < data/vehicle-etl/output/01_engines.sql
docker exec -i mvp-postgres psql -U postgres -d motovaultpro < data/vehicle-etl/output/02_transmissions.sql
docker exec -i mvp-postgres psql -U postgres -d motovaultpro < data/vehicle-etl/output/03_vehicle_options.sql
- echo "Flushing Redis cache..."
- docker exec mvp-redis redis-cli FLUSHALL
- echo "Vehicle ETL import completed"
- echo "Step 7/7 Starting all services..."
- docker compose -f $DOCKER_COMPOSE_FILE -f $DOCKER_COMPOSE_PROD_FILE up -d
- echo "Waiting for services to initialize..."
- sleep 30
@@ -125,7 +135,7 @@ verify:
- |
HEALTH_OK=0
for i in 1 2 3 4 5 6; do
if curl -sf http://localhost:3001/health > /dev/null 2>&1; then
if docker compose -f $DOCKER_COMPOSE_FILE exec -T mvp-backend curl -sf http://localhost:3001/health > /dev/null 2>&1; then
echo "OK: Backend health check passed"
HEALTH_OK=1
break
@@ -140,7 +150,7 @@ verify:
fi
- echo "Checking frontend..."
- |
if curl -sf http://localhost:3000 > /dev/null 2>&1; then
if docker compose -f $DOCKER_COMPOSE_FILE exec -T mvp-frontend curl -sf http://localhost:3000 > /dev/null 2>&1; then
echo "OK: Frontend is accessible"
else
echo "WARNING: Frontend check failed (might need Traefik routing)"