@@ -26,35 +26,50 @@ phases:
2626 - ' [ -n "$DATABASE_URL" ] || { echo "❌ DATABASE_URL is not set"; exit 1; }'
2727 - ' [ -n "$BASE_URL" ] || { echo "❌ BASE_URL is not set"; exit 1; }'
2828
29- # Install dependencies
30- - echo "Installing dependencies..."
31- - bun install --frozen-lockfile
32-
33- # Generate Prisma client
34- - echo "Generating Prisma client..."
35- - cd packages/db && bun x prisma generate && cd ../../
29+ # Install only API workspace dependencies
30+ - echo "Installing API dependencies only..."
31+ - bun install --filter=@comp/api --frozen-lockfile
3632
37- # Build NestJS application
33+ # Build NestJS application (prebuild automatically handles Prisma)
3834 - echo "Building NestJS application..."
39- - cd apps/$APP_NAME && bun run build && cd ../../
35+ - echo "APP_NAME is set to $APP_NAME"
36+ - echo "Current directory $(pwd)"
37+ - echo "Available apps $(ls -la apps/)"
38+ - cd apps/api
39+ - echo "Changed to $(pwd)"
40+ - echo "Running build (includes automatic prebuild db:generate)..."
41+ - bun run build
42+
43+ # Verify build output exists
44+ - echo "Checking build output..."
45+ - ls -la dist/
46+ - ls -la dist/src/
47+ - ' [ -f "dist/src/main.js" ] || { echo "❌ main.js not found in dist/src"; exit 1; }'
4048
41- # Create self-contained bundle for Docker
49+ # Create self-contained bundle for Docker (stay in apps/api)
4250 - echo "Creating self-contained bundle..."
43- - cd apps/$APP_NAME
4451 - mkdir -p ../docker-build
4552
46- # Copy built application
53+ # Copy built application (preserves NestJS structure)
54+ - echo "Copying built application..."
4755 - cp -r dist/* ../docker-build/
4856
49- # Copy entire node_modules for runtime (simpler and comprehensive)
57+ # Copy prisma folder (needed for runtime imports)
58+ - echo "Copying prisma folder..."
59+ - cp -r prisma ../docker-build/
60+
61+ # Verify files were copied correctly
62+ - echo "Verifying copied files..."
63+ - ls -la ../docker-build/
64+ - ls -la ../docker-build/src/
65+ - ' [ -f "../docker-build/src/main.js" ] || { echo "❌ main.js not found in docker-build/src"; exit 1; }'
66+
67+ # Copy entire node_modules for runtime (includes @trycompai/db from npm)
5068 - echo "Bundling all runtime dependencies..."
5169 - cp -r ../../node_modules ../docker-build/
5270
53- # Copy @trycompai/db package
54- - mkdir -p ../docker-build/node_modules/@trycompai
55- - cp -r ../../packages/db ../docker-build/node_modules/@trycompai/
56-
5771 # Copy Dockerfile
72+ - echo "Copying Dockerfile..."
5873 - cp Dockerfile ../docker-build/
5974
6075 # Build Docker image
@@ -69,7 +84,7 @@ phases:
6984 - docker push $ECR_REPOSITORY_URI:latest
7085 - echo "Updating ECS service..."
7186 - aws ecs update-service --cluster $ECS_CLUSTER_NAME --service $ECS_SERVICE_NAME --force-new-deployment
72- - ' printf "[{\"name\":\"%s-container\",\"imageUri\":\"%s\"}]" $APP_NAME $ECR_REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json'
87+ - ' printf "[{\"name\":\"%s-container\",\"imageUri\":\"%s\"}]" api $ECR_REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json'
7388
7489cache :
7590 paths :
0 commit comments