feat(deployment): update semaphore configuration and deployment workflows
This commit is contained in:
@@ -34,3 +34,13 @@ application_wait_interval: 5
|
||||
|
||||
# Command executed inside the app container to run migrations
|
||||
application_migration_command: "php console.php db:migrate"
|
||||
|
||||
# Environment (production, staging, local)
|
||||
# Determines which compose files to use and service names
|
||||
application_environment: "{{ APP_ENV | default('production') }}"
|
||||
|
||||
# Compose file suffix based on environment
|
||||
application_compose_suffix: "{{ 'staging.yml' if application_environment == 'staging' else 'production.yml' }}"
|
||||
|
||||
# Service names based on environment
|
||||
application_service_name: "{{ 'staging-app' if application_environment == 'staging' else 'php' }}"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
- name: Wait for application container to report Up
|
||||
shell: |
|
||||
docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.production.yml ps php | grep -Eiq "Up|running"
|
||||
docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.{{ application_compose_suffix }} ps {{ application_service_name }} | grep -Eiq "Up|running"
|
||||
register: application_app_running
|
||||
changed_when: false
|
||||
until: application_app_running.rc == 0
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
- name: Ensure app container is running before migrations
|
||||
shell: |
|
||||
docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.production.yml ps php | grep -Eiq "Up|running"
|
||||
docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.{{ application_compose_suffix }} ps {{ application_service_name }} | grep -Eiq "Up|running"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: application_app_container_running
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
- name: Run database migrations
|
||||
shell: |
|
||||
docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.production.yml exec -T php {{ application_migration_command }}
|
||||
docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.{{ application_compose_suffix }} exec -T {{ application_service_name }} {{ application_migration_command }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: application_migration_result
|
||||
@@ -43,7 +43,7 @@
|
||||
- application_app_container_running.rc == 0
|
||||
|
||||
- name: Collect application container status
|
||||
shell: docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.production.yml ps
|
||||
shell: docker compose -f {{ application_stack_dest }}/docker-compose.base.yml -f {{ application_stack_dest }}/docker-compose.{{ application_compose_suffix }} ps
|
||||
register: application_ps
|
||||
changed_when: false
|
||||
ignore_errors: yes
|
||||
|
||||
@@ -80,11 +80,11 @@
|
||||
register: application_compose_base_src
|
||||
become: no
|
||||
|
||||
- name: Check if application docker-compose.production.yml source exists locally
|
||||
- name: Check if application docker-compose override file exists locally (production or staging)
|
||||
stat:
|
||||
path: "{{ application_stack_src }}/../../../docker-compose.production.yml"
|
||||
path: "{{ application_stack_src }}/../../../docker-compose.{{ application_compose_suffix }}"
|
||||
delegate_to: localhost
|
||||
register: application_compose_prod_src
|
||||
register: application_compose_override_src
|
||||
become: no
|
||||
|
||||
- name: Copy application docker-compose.base.yml to target host
|
||||
@@ -96,14 +96,14 @@
|
||||
mode: '0644'
|
||||
when: application_compose_base_src.stat.exists
|
||||
|
||||
- name: Copy application docker-compose.production.yml to target host
|
||||
- name: Copy application docker-compose override file to target host (production or staging)
|
||||
copy:
|
||||
src: "{{ application_stack_src }}/../../../docker-compose.production.yml"
|
||||
dest: "{{ application_stack_dest }}/docker-compose.production.yml"
|
||||
src: "{{ application_stack_src }}/../../../docker-compose.{{ application_compose_suffix }}"
|
||||
dest: "{{ application_stack_dest }}/docker-compose.{{ application_compose_suffix }}"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
mode: '0644'
|
||||
when: application_compose_prod_src.stat.exists
|
||||
when: application_compose_override_src.stat.exists
|
||||
|
||||
- name: Check if legacy docker-compose.yml exists (fallback)
|
||||
stat:
|
||||
|
||||
Reference in New Issue
Block a user