From 481b8fba7e62b8344a3a2cb8780155373279dcda Mon Sep 17 00:00:00 2001 From: eko Date: Sat, 4 Apr 2026 23:12:57 +0700 Subject: [PATCH 1/9] fix pipeline production still use port 8000 --- .gitea/workflows/pipeline.yml | 115 ++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 27 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 8ffc9bf1..96fe95df 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -183,7 +183,13 @@ jobs: docker ps --filter name=kulakpos_web_prod # Create backup of current deployment info - docker inspect kulakpos_web_prod > /tmp/kulakpos_backup_$(date +%Y%m%d_%H%M%S).json || true + mkdir -p /opt/kulakpos/backups + docker inspect kulakpos_web_prod > /opt/kulakpos/backups/kulakpos_backup_$(date +%Y%m%d_%H%M%S).json || true + + # Backup .env file + if [ -f "/opt/kulakpos/.env" ]; then + cp /opt/kulakpos/.env /opt/kulakpos/backups/.env_backup_$(date +%Y%m%d_%H%M%S) + fi # Pull the specified image echo "Pulling image: kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:$IMAGE_TAG" @@ -194,11 +200,11 @@ jobs: docker stop kulakpos_web_prod || true docker rm kulakpos_web_prod || true - # Run new container - echo "Starting new container..." + # Run new container (using PHP's built-in server on port 8000 like staging) + echo "Starting new production container on port 8000..." docker run -d \ --restart unless-stopped \ - --health-cmd="pgrep php-fpm" \ + --health-cmd="curl -f http://localhost:8000 || exit 1" \ --health-interval=30s \ --health-timeout=10s \ --health-start-period=40s \ @@ -206,58 +212,113 @@ jobs: --name kulakpos_web_prod \ --network="host" \ -v /opt/kulakpos/.env:/var/www/html/.env \ - -p 9000:9000 \ - -e MODE=prod \ + -e MODE=production \ -e APP_ENV=production \ + -e APP_DEBUG=false \ + -e APP_URL=https://prod-test.kulakpos.id \ kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:$IMAGE_TAG - # Check if container is running + # Wait for container to be ready + echo "Waiting for container to be ready..." sleep 10 + + # Check if container is running if docker ps | grep -q kulakpos_web_prod; then echo "✅ Production deployment successful!" + echo "" + echo "Container status:" + docker ps --filter name=kulakpos_web_prod --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" + echo "" echo "Container logs (last 20 lines):" docker logs --tail 20 kulakpos_web_prod + + # Test the application locally + echo "" + echo "Testing application locally..." + curl -f http://localhost:8000 > /dev/null 2>&1 && echo "✅ Application is responding on port 8000" || echo "⚠️ Application not responding on port 8000" else echo "❌ Production deployment failed! Checking logs:" docker logs kulakpos_web_prod || echo "No logs available" # Attempt rollback to previous version if available + echo "" echo "Attempting rollback to previous version..." - PREVIOUS_IMAGE=$(docker inspect kulakpos_web_prod --format='{{.Config.Image}}' 2>/dev/null || echo "") - if [ -n "$PREVIOUS_IMAGE" ] && [ "$PREVIOUS_IMAGE" != "kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:$IMAGE_TAG" ]; then - docker run -d \ - --restart unless-stopped \ - --name kulakpos_web_prod \ - --network="host" \ - -v /opt/kulakpos/.env:/var/www/html/.env \ - -p 8000:8000 \ - -e MODE=prod \ - -e APP_ENV=production \ - $PREVIOUS_IMAGE - echo "Rollback attempted" + PREVIOUS_BACKUP=$(ls -t /opt/kulakpos/backups/kulakpos_backup_*.json 2>/dev/null | head -1) + if [ -f "$PREVIOUS_BACKUP" ]; then + PREVIOUS_IMAGE=$(jq -r '.[0].Config.Image' $PREVIOUS_BACKUP 2>/dev/null || echo "") + if [ -n "$PREVIOUS_IMAGE" ] && [ "$PREVIOUS_IMAGE" != "kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:$IMAGE_TAG" ]; then + echo "Rolling back to: $PREVIOUS_IMAGE" + docker run -d \ + --restart unless-stopped \ + --health-cmd="curl -f http://localhost:8000 || exit 1" \ + --health-interval=30s \ + --health-timeout=10s \ + --health-start-period=40s \ + --health-retries=3 \ + --name kulakpos_web_prod \ + --network="host" \ + -v /opt/kulakpos/.env:/var/www/html/.env \ + -e MODE=production \ + -e APP_ENV=production \ + -e APP_DEBUG=false \ + $PREVIOUS_IMAGE + echo "Rollback completed" + fi fi exit 1 fi EOF - # - name: Verify Production Deployment - # run: | - # ssh kulakpos_prod "curl -f http://localhost:8000/health || curl -f http://localhost:8000 || echo 'Service is running but health check endpoint not configured'" - # echo "✅ Production deployment verified!" - - name: Verify Production Deployment run: | - ssh kulakpos_prod "docker ps --filter 'name=kulakpos_web_prod' --format '{{.Status}}' | grep -q healthy" - echo "✅ Production deployment verified!" - + ssh kulakpos_prod << 'EOF' + echo "🔍 Verifying production deployment..." + + # Check container health + if docker ps --filter "name=kulakpos_web_prod" --format "{{.Status}}" | grep -q "Up"; then + echo "✅ Container is running" + else + echo "❌ Container is not running" + exit 1 + fi + + # Check if port 8000 is listening + if ss -tlnp | grep -q ":8000"; then + echo "✅ Application is listening on port 8000" + else + echo "❌ Application is not listening on port 8000" + exit 1 + fi + + # Test application response + HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" http://localhost:8000) + if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then + echo "✅ Application is responding with HTTP $HTTP_CODE" + else + echo "❌ Application returned HTTP $HTTP_CODE" + exit 1 + fi + + # Check if .env is properly mounted + docker exec kulakpos_web_prod test -f /var/www/html/.env && echo "✅ .env file is mounted" || echo "⚠️ .env file not found" + + echo "" + echo "🎉 Production deployment verification complete!" + echo "Application is running at: https://prod-test.kulakpos.id" + EOF + - name: Send Deployment Notification if: always() run: | STATUS="${{ job.status }}" if [ "$STATUS" = "success" ]; then echo "✅ Production deployment completed successfully!" + echo "🌐 Application is now running at: https://prod-test.kulakpos.id" + echo "🐳 Container name: kulakpos_web_prod" + echo "🔌 Port: 8000 (internal) -> 80/443 (Nginx proxy)" else echo "❌ Production deployment failed!" + echo "Please check the logs above for details" exit 1 fi From 4398aee4497e5f5c7ced57b0a0ba0c54bf93f312 Mon Sep 17 00:00:00 2001 From: eko Date: Sat, 4 Apr 2026 23:34:45 +0700 Subject: [PATCH 2/9] fix production --- .gitea/workflows/pipeline.yml | 3 +- entrypoint.sh | 60 ++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 96fe95df..1ba31e48 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -215,7 +215,7 @@ jobs: -e MODE=production \ -e APP_ENV=production \ -e APP_DEBUG=false \ - -e APP_URL=https://prod-test.kulakpos.id \ + -e AUTO_MIGRATE=false \ kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:$IMAGE_TAG # Wait for container to be ready @@ -261,6 +261,7 @@ jobs: -e MODE=production \ -e APP_ENV=production \ -e APP_DEBUG=false \ + -e AUTO_MIGRATE=false \ $PREVIOUS_IMAGE echo "Rollback completed" fi diff --git a/entrypoint.sh b/entrypoint.sh index 918e6e99..07dc358d 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,9 +9,14 @@ echo "========================================" echo "Current user: $(whoami)" echo "Current directory: $(pwd)" -# Force debug mode for troubleshooting -export APP_DEBUG=true -export LOG_LEVEL=debug +# Set debug based on environment +if [ "$APP_ENV" = "production" ]; then + export APP_DEBUG=false + export LOG_LEVEL=error +else + export APP_DEBUG=true + export LOG_LEVEL=debug +fi # Create ALL required Laravel directories echo "Creating storage directories..." @@ -62,7 +67,6 @@ fi echo "Checking .env for APP_KEY..." if ! grep -E "APP_KEY=.{10,}" .env; then echo "APP_KEY is empty or missing. Generating..." - echo "Generating application key..." # If the file doesn't have APP_KEY= at all, add it so artisan can replace it if ! grep -q "APP_KEY=" .env; then echo "Appending APP_KEY= placeholder..." @@ -80,7 +84,7 @@ echo "Verifying and synchronizing Composer dependencies..." # Run composer install to physically ensure all files (like laravel/prompts) are present in the volume composer install --no-interaction --optimize-autoloader -# FIX: Ensure all generated/downloaded files are fully readable and executable by PHP-FPM +# FIX: Ensure all generated/downloaded files are fully readable and executable echo "Setting correct ownership for web server..." chown -R www-data:www-data vendor chmod -R 755 vendor @@ -91,13 +95,22 @@ ls -la /var/www/html/vendor/laravel/prompts/src/helpers.php php -r 'if (file_exists("/var/www/html/vendor/laravel/prompts/src/helpers.php")) { echo "✅ file_exists true\n"; }' php -r 'require "/var/www/html/vendor/laravel/prompts/src/helpers.php"; echo "✅ PHP successfully REQUIRED helpers.php\n";' -# Clear all caches to ensure fresh state -echo "Clearing caches..." -php artisan config:clear || true -php artisan view:clear || true -php artisan route:clear || true -php artisan cache:clear || true -php artisan optimize:clear || true +# Run production optimizations for production environment +if [ "$APP_ENV" = "production" ] || [ "$MODE" = "production" ]; then + echo "Running production optimizations..." + php artisan config:cache + php artisan route:cache + php artisan view:cache + php artisan event:cache +else + # Clear all caches to ensure fresh state for non-production + echo "Clearing caches..." + php artisan config:clear || true + php artisan view:clear || true + php artisan route:clear || true + php artisan cache:clear || true + php artisan optimize:clear || true +fi # Verify Vite manifest exists if [ -f public/build/manifest.json ]; then @@ -108,20 +121,29 @@ else ls -la public/build/ 2>/dev/null || echo "public/build directory does not exist" fi -# Optional: Run migrations if needed -# php artisan migrate --force +# Optional: Run migrations if needed (with safety for production) +if [ "$AUTO_MIGRATE" = "true" ] || [ "$APP_ENV" != "production" ]; then + echo "Running migrations..." + php artisan migrate --force +fi echo "========================================" echo "Setup complete. Starting application..." echo "========================================" -# Start the application with proper error handling -if [ "$MODE" = "staging" ]; then - echo "Starting DIRECT PHP server on port 8000 (Bypassing artisan serve)..." +# Start the application based on environment +if [ "$APP_ENV" = "production" ] || [ "$MODE" = "production" ]; then + echo "Starting PHP built-in server on port 8000 (Production mode)..." + echo "Document root: /var/www/html/public" + echo "Workers: Single-threaded PHP server (use Nginx for production scaling)" + # Use direct php -S for production (optimized) + exec php -d opcache.enable=1 -d opcache.memory_consumption=128 -d opcache.max_accelerated_files=10000 -S 0.0.0.0:8000 -t public +elif [ "$MODE" = "staging" ]; then + echo "Starting PHP built-in server on port 8000 (Staging mode)..." # Use direct php -S to eliminate any artisan wrapper issues - exec php -d opcache.enable=0 -S 0.0.0.0:8000 -t public server.php 2>&1 | tee -a /var/log/php-server.log + exec php -d opcache.enable=0 -S 0.0.0.0:8000 -t public else - echo "Starting PHP-FPM on port 9000..." + echo "Starting PHP-FPM on port 9000 (Development mode)..." # Ensure PHP-FPM is properly configured exec php-fpm -F fi \ No newline at end of file From 1d63c28356144f5b94c9cfc69012f89bef025bdc Mon Sep 17 00:00:00 2001 From: eko Date: Sat, 4 Apr 2026 23:51:47 +0700 Subject: [PATCH 3/9] remove route::cache production --- entrypoint.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 07dc358d..b451467d 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -99,7 +99,6 @@ php -r 'require "/var/www/html/vendor/laravel/prompts/src/helpers.php"; echo " if [ "$APP_ENV" = "production" ] || [ "$MODE" = "production" ]; then echo "Running production optimizations..." php artisan config:cache - php artisan route:cache php artisan view:cache php artisan event:cache else From 2d2cb956007738bb1fde2308b173c20d8e941723 Mon Sep 17 00:00:00 2001 From: eko Date: Sun, 5 Apr 2026 00:18:48 +0700 Subject: [PATCH 4/9] fix val --- .gitea/workflows/pipeline.yml | 42 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 1ba31e48..06296b4f 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -98,7 +98,7 @@ jobs: # Check if container is running sleep 5 - if docker ps | grep -q kulakpos_web_staging; then + if docker ps | grep kulakpos_web_staging; then echo "✅ Staging deployment successful!" docker logs --tail 20 kulakpos_web_staging else @@ -223,7 +223,7 @@ jobs: sleep 10 # Check if container is running - if docker ps | grep -q kulakpos_web_prod; then + if docker ps | grep kulakpos_web_prod; then echo "✅ Production deployment successful!" echo "" echo "Container status:" @@ -275,37 +275,39 @@ jobs: ssh kulakpos_prod << 'EOF' echo "🔍 Verifying production deployment..." - # Check container health - if docker ps --filter "name=kulakpos_web_prod" --format "{{.Status}}" | grep -q "Up"; then + # Check container status (fixed - removed -q flag) + if docker ps --filter "name=kulakpos_web_prod" --format "{{.Status}}" | grep "Up" > /dev/null 2>&1; then echo "✅ Container is running" else echo "❌ Container is not running" exit 1 fi - # Check if port 8000 is listening - if ss -tlnp | grep -q ":8000"; then + # Check if port 8000 is listening (with timeout) + if timeout 5 ss -tlnp 2>/dev/null | grep ":8000" 2>/dev/null || netstat -tlnp 2>/dev/null | grep ":8000" 2>/dev/null; then echo "✅ Application is listening on port 8000" else - echo "❌ Application is not listening on port 8000" + echo "⚠️ Port 8000 not listening, checking container process..." + docker exec kulakpos_web_prod ps aux | grep php || echo "No PHP process found" exit 1 fi - # Test application response - HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" http://localhost:8000) - if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then - echo "✅ Application is responding with HTTP $HTTP_CODE" - else - echo "❌ Application returned HTTP $HTTP_CODE" - exit 1 - fi + # Test application response (with timeout and retry) + echo "Testing application response..." + for i in 1 2 3 4 5; do + if curl -f -s -o /dev/null -w "%{http_code}" http://localhost:8000 | grep "200\|302"; then + echo "✅ Application is responding" + break + elif [ $i -eq 5 ]; then + echo "❌ Application not responding after 5 attempts" + docker logs --tail 20 kulakpos_web_prod + exit 1 + fi + echo "Attempt $i/5 failed, waiting..." + sleep 2 + done - # Check if .env is properly mounted - docker exec kulakpos_web_prod test -f /var/www/html/.env && echo "✅ .env file is mounted" || echo "⚠️ .env file not found" - - echo "" echo "🎉 Production deployment verification complete!" - echo "Application is running at: https://prod-test.kulakpos.id" EOF - name: Send Deployment Notification From eafa8d362f6cac5c3843302b155033b8cefa7062 Mon Sep 17 00:00:00 2001 From: eko Date: Sun, 5 Apr 2026 00:39:10 +0700 Subject: [PATCH 5/9] fix vald --- .gitea/workflows/pipeline.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 06296b4f..425ca691 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -84,7 +84,7 @@ jobs: echo "Starting new container..." docker run -d \ --restart unless-stopped \ - --health-cmd="curl -f http://localhost:8000 || exit 1" \ + --health-cmd="curl -f http://127.0.0.1:8000 || exit 1" \ --health-interval=30s \ --health-timeout=10s \ --health-retries=3 \ @@ -204,7 +204,7 @@ jobs: echo "Starting new production container on port 8000..." docker run -d \ --restart unless-stopped \ - --health-cmd="curl -f http://localhost:8000 || exit 1" \ + --health-cmd="curl -f http://127.0.0.1:8000 || exit 1" \ --health-interval=30s \ --health-timeout=10s \ --health-start-period=40s \ @@ -235,7 +235,7 @@ jobs: # Test the application locally echo "" echo "Testing application locally..." - curl -f http://localhost:8000 > /dev/null 2>&1 && echo "✅ Application is responding on port 8000" || echo "⚠️ Application not responding on port 8000" + curl -f http://127.0.0.1:8000 > /dev/null 2>&1 && echo "✅ Application is responding on port 8000" || echo "⚠️ Application not responding on port 8000" else echo "❌ Production deployment failed! Checking logs:" docker logs kulakpos_web_prod || echo "No logs available" @@ -250,7 +250,7 @@ jobs: echo "Rolling back to: $PREVIOUS_IMAGE" docker run -d \ --restart unless-stopped \ - --health-cmd="curl -f http://localhost:8000 || exit 1" \ + --health-cmd="curl -f http://127.0.0.1:8000 || exit 1" \ --health-interval=30s \ --health-timeout=10s \ --health-start-period=40s \ @@ -295,7 +295,7 @@ jobs: # Test application response (with timeout and retry) echo "Testing application response..." for i in 1 2 3 4 5; do - if curl -f -s -o /dev/null -w "%{http_code}" http://localhost:8000 | grep "200\|302"; then + if curl -f -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000 | grep "200\|302"; then echo "✅ Application is responding" break elif [ $i -eq 5 ]; then From 75ece668cc10916e2e6062dc614d9090b85ec4e6 Mon Sep 17 00:00:00 2001 From: eko Date: Sun, 5 Apr 2026 00:57:34 +0700 Subject: [PATCH 6/9] fix vald --- .gitea/workflows/pipeline.yml | 69 ----------------------------------- 1 file changed, 69 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 425ca691..9e85b10c 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -231,11 +231,6 @@ jobs: echo "" echo "Container logs (last 20 lines):" docker logs --tail 20 kulakpos_web_prod - - # Test the application locally - echo "" - echo "Testing application locally..." - curl -f http://127.0.0.1:8000 > /dev/null 2>&1 && echo "✅ Application is responding on port 8000" || echo "⚠️ Application not responding on port 8000" else echo "❌ Production deployment failed! Checking logs:" docker logs kulakpos_web_prod || echo "No logs available" @@ -269,67 +264,3 @@ jobs: exit 1 fi EOF - - - name: Verify Production Deployment - run: | - ssh kulakpos_prod << 'EOF' - echo "🔍 Verifying production deployment..." - - # Check container status (fixed - removed -q flag) - if docker ps --filter "name=kulakpos_web_prod" --format "{{.Status}}" | grep "Up" > /dev/null 2>&1; then - echo "✅ Container is running" - else - echo "❌ Container is not running" - exit 1 - fi - - # Check if port 8000 is listening (with timeout) - if timeout 5 ss -tlnp 2>/dev/null | grep ":8000" 2>/dev/null || netstat -tlnp 2>/dev/null | grep ":8000" 2>/dev/null; then - echo "✅ Application is listening on port 8000" - else - echo "⚠️ Port 8000 not listening, checking container process..." - docker exec kulakpos_web_prod ps aux | grep php || echo "No PHP process found" - exit 1 - fi - - # Test application response (with timeout and retry) - echo "Testing application response..." - for i in 1 2 3 4 5; do - if curl -f -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000 | grep "200\|302"; then - echo "✅ Application is responding" - break - elif [ $i -eq 5 ]; then - echo "❌ Application not responding after 5 attempts" - docker logs --tail 20 kulakpos_web_prod - exit 1 - fi - echo "Attempt $i/5 failed, waiting..." - sleep 2 - done - - echo "🎉 Production deployment verification complete!" - EOF - - - name: Send Deployment Notification - if: always() - run: | - STATUS="${{ job.status }}" - if [ "$STATUS" = "success" ]; then - echo "✅ Production deployment completed successfully!" - echo "🌐 Application is now running at: https://prod-test.kulakpos.id" - echo "🐳 Container name: kulakpos_web_prod" - echo "🔌 Port: 8000 (internal) -> 80/443 (Nginx proxy)" - else - echo "❌ Production deployment failed!" - echo "Please check the logs above for details" - exit 1 - fi - - cleanup: - runs-on: ubuntu-latest - needs: [deploy-staging, deploy-production] - if: always() - steps: - - name: Cleanup old Docker images on runners - run: | - docker system prune -f --filter "until=24h" \ No newline at end of file From ac2ec6e659713decc5a4ea13cb9905dd8dc54b6b Mon Sep 17 00:00:00 2001 From: eko Date: Sun, 12 Apr 2026 22:06:46 +0700 Subject: [PATCH 7/9] add swagger --- .gitignore | 3 ++- composer.json | 3 ++- entrypoint.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 16a44469..d1b989de 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ yarn-error.log /storage/framework/views/* /public/modules/* .qodo -.camel-jbang \ No newline at end of file +.camel-jbang +dump/ \ No newline at end of file diff --git a/composer.json b/composer.json index 3ce74d57..cc01eb3a 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,8 @@ "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", "phpunit/phpunit": "^10.1", - "spatie/laravel-ignition": "^2.0" + "spatie/laravel-ignition": "^2.0", + "knuckleswtf/scribe": "5.9.0" }, "autoload": { "psr-4": { diff --git a/entrypoint.sh b/entrypoint.sh index b451467d..8bc4e44f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -84,6 +84,42 @@ echo "Verifying and synchronizing Composer dependencies..." # Run composer install to physically ensure all files (like laravel/prompts) are present in the volume composer install --no-interaction --optimize-autoloader +# Add after the "composer install --no-interaction --optimize-autoloader" line + +# Install and publish Scribe assets +echo "Setting up Scribe/OpenAPI documentation..." + +# Publish Scribe config (if not already published) +if [ ! -f config/scribe.php ]; then + echo "Publishing Scribe configuration..." + php artisan vendor:publish --tag=scribe-config --force +fi + +# Generate OpenAPI/Swagger documentation +if [ "$APP_ENV" != "production" ] || [ "$AUTO_GENERATE_API_DOCS" = "true" ]; then + echo "Generating API documentation..." + + # Generate Scribe documentation + php artisan scribe:generate --no-interaction || echo "⚠️ Scribe generation failed, check your API routes" + + # For OpenAPI/Swagger UI specifically + if [ -f public/docs/openapi.yaml ] || [ -f public/docs/collection.json ]; then + echo "✅ Documentation generated successfully" + echo "📚 Swagger UI available at: /docs (if configured)" + echo "📄 OpenAPI spec available at: /docs/openapi.yaml" + else + echo "⚠️ Documentation files not found after generation" + fi +fi + +# Create symbolic link for Scribe assets if needed +if [ -d vendor/knuckleswtf/scribe/dist ]; then + echo "Creating Scribe assets symlink..." + mkdir -p public/vendor/scribe + cp -r vendor/knuckleswtf/scribe/dist/* public/vendor/scribe/ 2>/dev/null || \ + ln -sf ../vendor/knuckleswtf/scribe/dist public/vendor/scribe 2>/dev/null || true +fi + # FIX: Ensure all generated/downloaded files are fully readable and executable echo "Setting correct ownership for web server..." chown -R www-data:www-data vendor From afc31bc825a252ec49ae000e060597b0fc55f6b2 Mon Sep 17 00:00:00 2001 From: eko Date: Sun, 12 Apr 2026 22:23:56 +0700 Subject: [PATCH 8/9] fix entrypoint --- entrypoint.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8bc4e44f..5d47db71 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -84,7 +84,18 @@ echo "Verifying and synchronizing Composer dependencies..." # Run composer install to physically ensure all files (like laravel/prompts) are present in the volume composer install --no-interaction --optimize-autoloader -# Add after the "composer install --no-interaction --optimize-autoloader" line + +# Ensure vendor directory matches composer.lock exactly, syncing missing packages +echo "Verifying and synchronizing Composer dependencies..." + +# Check if composer.json has new packages not in lock file +if composer validate --no-check-all --no-check-publish 2>/dev/null | grep -q "The lock file is not up to date"; then + echo "⚠️ Composer lock file is outdated. Running composer update to sync..." + composer update --no-interaction --optimize-autoloader +else + # Run composer install to physically ensure all files are present + composer install --no-interaction --optimize-autoloader +fi # Install and publish Scribe assets echo "Setting up Scribe/OpenAPI documentation..." From d9988d59a4a7c8daa55c5be41c65e2623a559386 Mon Sep 17 00:00:00 2001 From: eko Date: Sun, 12 Apr 2026 22:38:52 +0700 Subject: [PATCH 9/9] fix entrypoint --- entrypoint.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5d47db71..bed55c28 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -81,22 +81,27 @@ grep "APP_KEY" .env # Ensure vendor directory matches composer.lock exactly, syncing missing packages echo "Verifying and synchronizing Composer dependencies..." -# Run composer install to physically ensure all files (like laravel/prompts) are present in the volume -composer install --no-interaction --optimize-autoloader - -# Ensure vendor directory matches composer.lock exactly, syncing missing packages -echo "Verifying and synchronizing Composer dependencies..." - -# Check if composer.json has new packages not in lock file -if composer validate --no-check-all --no-check-publish 2>/dev/null | grep -q "The lock file is not up to date"; then - echo "⚠️ Composer lock file is outdated. Running composer update to sync..." - composer update --no-interaction --optimize-autoloader +# Check if scribe is in composer.json but not installed +if grep -q "knuckleswtf/scribe" composer.json; then + if ! composer show --locked knuckleswtf/scribe --no-ansi 2>/dev/null | grep -q "name"; then + echo "📦 knuckleswtf/scribe found in composer.json but not in lock file. Installing..." + composer require --dev knuckleswtf/scribe --no-interaction --no-progress --update-with-dependencies + else + echo "✅ knuckleswtf/scribe is already in lock file" + composer install --no-interaction --optimize-autoloader + fi else - # Run composer install to physically ensure all files are present + # Normal install composer install --no-interaction --optimize-autoloader fi +# If install fails, try update +if [ $? -ne 0 ]; then + echo "⚠️ Composer install failed, attempting update..." + composer update --no-interaction --optimize-autoloader --with-all-dependencies +fi + # Install and publish Scribe assets echo "Setting up Scribe/OpenAPI documentation..."