Split the build pipeline: one compile-services job builds all 8 service binaries with PVC-backed sccache, saves as artifacts. Then 9 Kaniko jobs just package pre-built binaries into slim runtime images (~30s each). Before: 9 parallel Kaniko jobs each doing full cargo build --release (~20min each, no sccache, 9x duplicated dep compilation) After: 1 compile job with sccache (~5min cached) + 9 package jobs (~30s) - Add compile stage between test and build - Add Dockerfile.runtime (minimal debian + pre-built binary) - Add Dockerfile.web-gateway-runtime (Node dashboard + pre-built binary) - Keep Dockerfile.training via Kaniko (needs CUDA dev image for H100) - Remove all SCCACHE_BUCKET build-args from service builds - Use dir:// context for Kaniko (only sends build-out/ dir, not full repo) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
80 lines
2.3 KiB
Bash
Executable File
80 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Script to prepare SQLx for offline compilation
|
|
# This script sets up the necessary files for SQLx compile-time verification
|
|
|
|
set -e
|
|
|
|
echo "Setting up SQLx for offline compilation..."
|
|
|
|
# Create .sqlx directory if it doesn't exist
|
|
mkdir -p .sqlx
|
|
|
|
# Set DATABASE_URL from .env file
|
|
export DATABASE_URL=postgresql://localhost/foxhunt
|
|
|
|
echo "DATABASE_URL set to: $DATABASE_URL"
|
|
|
|
# Try to prepare SQLx queries (this will fail without a database, but we'll handle that)
|
|
echo "Attempting to prepare SQLx queries..."
|
|
if cargo sqlx prepare --database-url="$DATABASE_URL" 2>/dev/null; then
|
|
echo "✅ SQLx preparation successful!"
|
|
else
|
|
echo "⚠️ SQLx preparation failed (expected without live database)"
|
|
echo "Creating minimal sqlx-data.json for offline compilation..."
|
|
|
|
# Create a comprehensive sqlx-data.json with empty queries
|
|
cat > sqlx-data.json << 'EOF'
|
|
{
|
|
"db": "PostgreSQL",
|
|
"queries": {},
|
|
"version": "0.8.0"
|
|
}
|
|
EOF
|
|
|
|
echo "✅ Created minimal sqlx-data.json"
|
|
fi
|
|
|
|
# Create a database initialization script
|
|
cat > scripts/init-db-dev.sql << 'EOF'
|
|
-- Development Database Initialization Script
|
|
-- This script creates a minimal database structure for development
|
|
|
|
-- Create the foxhunt database
|
|
CREATE DATABASE foxhunt_trading;
|
|
|
|
-- Connect to the database
|
|
\c foxhunt_trading;
|
|
|
|
-- Create extensions
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
CREATE EXTENSION IF NOT EXISTS "btree_gin";
|
|
|
|
-- Include the existing init-db.sql content
|
|
\i scripts/init-db.sql
|
|
|
|
-- Apply all migrations in order
|
|
\i migrations/001_up_create_trading_engine_tables.sql
|
|
\i migrations/002_up_create_risk_performance_tables.sql
|
|
\i migrations/007_configuration_schema.sql
|
|
\i migrations/011_create_market_data_tables.sql
|
|
\i migrations/012_create_event_and_config_tables.sql
|
|
EOF
|
|
|
|
echo "✅ Created scripts/init-db-dev.sql"
|
|
|
|
# Check if we can compile now
|
|
echo "Testing compilation..."
|
|
if cargo check --workspace --quiet 2>/dev/null; then
|
|
echo "✅ Workspace compilation successful!"
|
|
else
|
|
echo "⚠️ Some compilation issues may still exist"
|
|
echo " This is expected if there are other dependency issues"
|
|
fi
|
|
|
|
echo "✅ SQLx offline setup complete!"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Set up a local PostgreSQL database"
|
|
echo "2. Run: psql -f scripts/init-db-dev.sql"
|
|
echo "3. Run: cargo sqlx prepare"
|
|
echo "4. Commit the generated .sqlx/ query files" |