fix: Add container status check and better error handling
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 56s
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 24s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 12s
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
Security Vulnerability Scan / Composer Security Audit (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Successful in 15s
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 1m3s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 56s
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 24s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 12s
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
Security Vulnerability Scan / Composer Security Audit (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Successful in 15s
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 1m3s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
- Check if container is running before executing composer - Start container if not running - Display detailed error output for debugging - Fixes composer install failures when container is not running
This commit is contained in:
@@ -35,6 +35,26 @@
|
||||
msg: "composer.json not found at /home/deploy/michaelschiemer/current/composer.json"
|
||||
when: not composer_json_exists.stat.exists
|
||||
|
||||
- name: Check if container is running
|
||||
shell: |
|
||||
cd {{ application_code_dest }}
|
||||
docker compose -f docker-compose.base.yml -f docker-compose.{{ application_compose_suffix }} ps {{ php_service_name }} --format json
|
||||
register: container_status
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Display container status
|
||||
debug:
|
||||
msg: "Container status: {{ container_status.stdout }}"
|
||||
|
||||
- name: Start container if not running
|
||||
shell: |
|
||||
cd {{ application_code_dest }}
|
||||
docker compose -f docker-compose.base.yml -f docker-compose.{{ application_compose_suffix }} up -d {{ php_service_name }}
|
||||
when: container_status.rc != 0 or '"State":"running"' not in container_status.stdout
|
||||
register: container_start
|
||||
changed_when: container_start.rc == 0
|
||||
|
||||
- name: Install composer dependencies in PHP container
|
||||
shell: |
|
||||
cd {{ application_code_dest }}
|
||||
@@ -43,6 +63,15 @@
|
||||
changed_when: true
|
||||
failed_when: composer_install.rc != 0
|
||||
|
||||
- name: Display composer install output
|
||||
debug:
|
||||
msg: |
|
||||
Composer Install Output:
|
||||
stdout: {{ composer_install.stdout }}
|
||||
stderr: {{ composer_install.stderr }}
|
||||
rc: {{ composer_install.rc }}
|
||||
when: composer_install.rc != 0
|
||||
|
||||
- name: Restart queue-worker and scheduler to pick up vendor directory (production only)
|
||||
shell: |
|
||||
cd {{ application_code_dest }}
|
||||
@@ -52,11 +81,6 @@
|
||||
failed_when: false
|
||||
when: deployment_environment == 'production'
|
||||
|
||||
- name: Display composer install output
|
||||
debug:
|
||||
msg: |
|
||||
Composer Install Output:
|
||||
{{ composer_install.stdout }}
|
||||
|
||||
- name: Verify vendor/autoload.php exists
|
||||
shell: |
|
||||
|
||||
Reference in New Issue
Block a user