88 build-and-deploy :
99 runs-on : self-hosted
1010 name : ' 🐳 Build & Deploy'
11+
1112 steps :
1213 - name : ' 🔍 Checkout Code'
1314 uses : actions/checkout@v4
15+ with :
16+ submodules : ' recursive'
1417
15- # (Secrets and .env setup steps remain the same)
1618 - name : ' 🔒 Verify Secrets Exist'
1719 run : |
1820 if [ -z "${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}" ]; then
4042 # =======================================================
4143 # 🐳 Docker Operations
4244 # =======================================================
43- - name : ' 🚀 Build, Launch, and Update Services'
45+ - name : ' � Debug: List workspace files and show package.json'
46+ run : |
47+ echo '--- DEBUG: Listing workspace files ---'
48+ ls -alh
49+ echo '--- DEBUG: Showing package.json ---'
50+ cat package.json
51+ echo '--- DEBUG: Listing node_modules/.bin if exists ---'
52+ if [ -d node_modules/.bin ]; then ls -l node_modules/.bin; else echo "node_modules/.bin does not exist"; fi
53+
54+ # Ensure the Postgres data volume exists before starting services
55+ - name : ' 🔧 Ensure Postgres data volume exists'
56+ run : |
57+ if [ -z "$(docker volume ls -q -f name=codebuilder-postgres-data)" ]; then
58+ echo "Volume 'codebuilder-postgres-data' not found. Creating it..."
59+ docker volume create codebuilder-postgres-data
60+ else
61+ echo "Volume 'codebuilder-postgres-data' already exists. Skipping creation."
62+ fi
63+
64+ - name : ' �🚀 Build, Launch, and Update Services'
4465 run : |
4566 # Step 1: Ensure the Docker network exists.
4667 if ! docker network ls | grep -q "codebuilder-net"; then
5980 fi
6081 else
6182 echo "Database container not found. Creating it..."
62- # Added -p flag to associate with the correct stack
63- docker compose -p codebuilder-frontend up -d db
83+ # Use 'codebuilder' as the stack prefix
84+ docker compose -p codebuilder up -d db
6485 fi
6586
6687 # Step 3: Wait for the database to be healthy.
@@ -75,19 +96,24 @@ jobs:
7596 echo "Ensuring build runs in default server mode..."
7697 export NEXT_OUTPUT_MODE='standalone'
7798
78- # Step 4: Build the new webapp image.
99+ # Step 4: Build the latest webapp image.
79100 echo "Building the latest webapp image..."
80- # Added -p flag to ensure build context is correct
81- docker compose -p codebuilder-frontend build webapp
101+ # Get the current commit hash of the prisma submodule
102+ # This ensures Docker rebuilds the prisma layer when the submodule is updated
103+ PRISMA_COMMIT=$(git submodule status prisma | awk '{print $1}' | sed 's/^+//')
104+ echo "Using Prisma submodule commit: $PRISMA_COMMIT"
105+
106+ # Force a complete rebuild with no cache to ensure fresh prisma schema
107+ docker compose -p codebuilder build --no-cache webapp
82108
83109 # Step 5: Forcefully remove the old webapp container to prevent conflicts.
84110 echo "Forcefully removing old webapp container if it exists..."
85111 docker rm -f codebuilder-webapp || true
86112
87113 # Step 6: Deploy the new webapp container.
88114 echo "Deploying the new webapp container..."
89- # Added -p flag to associate with the correct stack
90- docker compose -p codebuilder-frontend up -d --no-deps webapp
115+ # Use 'codebuilder' as the stack prefix
116+ docker compose -p codebuilder up -d --no-deps webapp
91117
92118 - name : ' 🗑 Prune Old Docker Images'
93119 if : always()
0 commit comments