mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Optimized code, so that 'docker compose up' can run until setup is finished without any interruptions
This commit is contained in:
@@ -5,35 +5,25 @@
|
||||
#- name: shut down docker compose project
|
||||
# command:
|
||||
# cmd: docker-compose -p "{{ application_id }}" down
|
||||
# listen: docker compose project setup
|
||||
# listen: docker compose up
|
||||
# when: mode_reset | bool
|
||||
|
||||
# default setup for docker compose files
|
||||
- name: docker compose project setup
|
||||
- name: docker compose up
|
||||
shell: >
|
||||
docker-compose -p {{ application_id }} up -d --force-recreate --remove-orphans
|
||||
2>&1 | tee >(systemd-cat -t docker-compose-{{ application_id }})
|
||||
args:
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
COMPOSE_HTTP_TIMEOUT: 600
|
||||
DOCKER_CLIENT_TIMEOUT: 600
|
||||
listen: docker compose project setup
|
||||
|
||||
# it's necessary to rebuild when a build in the docker compose files is defined
|
||||
# for performance reasons it's not recommended to use this if there is no build tag specified
|
||||
- name: docker compose project build and setup
|
||||
shell: >
|
||||
docker-compose -p {{ application_id }} up -d --force-recreate --build --remove-orphans
|
||||
2>&1 | tee >(systemd-cat -t docker-compose-{{ application_id }})
|
||||
docker-compose -p {{ application_id }} up -d
|
||||
--force-recreate --remove-orphans --build
|
||||
2>&1 | tee >(systemd-cat -t docker-compose-{{ application_id }})
|
||||
args:
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
COMPOSE_HTTP_TIMEOUT: 600
|
||||
DOCKER_CLIENT_TIMEOUT: 600
|
||||
listen: docker compose project build and setup
|
||||
listen: docker compose up
|
||||
|
||||
- name: docker compose restart
|
||||
command:
|
||||
|
@@ -2,7 +2,7 @@
|
||||
template:
|
||||
src: "{{ playbook_dir }}/roles/{{ role_name }}/templates/Dockerfile.j2"
|
||||
dest: "{{ docker_compose.files.dockerfile }}"
|
||||
notify: docker compose project build and setup
|
||||
notify: docker compose up
|
||||
ignore_errors: false
|
||||
register: create_dockerfile_result
|
||||
failed_when:
|
||||
@@ -15,7 +15,7 @@
|
||||
dest: "{{ docker_compose.files.env }}"
|
||||
mode: '770'
|
||||
force: yes
|
||||
notify: docker compose project setup
|
||||
notify: docker compose up
|
||||
register: env_template
|
||||
ignore_errors: false
|
||||
failed_when:
|
||||
@@ -26,7 +26,7 @@
|
||||
template:
|
||||
src: "docker-compose.yml.j2"
|
||||
dest: "{{ docker_compose.files.docker_compose }}"
|
||||
notify: docker compose project setup
|
||||
notify: docker compose up
|
||||
register: docker_compose_template
|
||||
|
||||
- name: "Check if any container is running in {{ docker_compose.directories.instance }}"
|
||||
@@ -35,8 +35,8 @@
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
register: docker_ps
|
||||
changed_when: (docker_ps.stdout | trim) == ""
|
||||
notify: docker compose project setup
|
||||
notify: docker compose up
|
||||
when: not (docker_compose_template.changed or env_template.changed)
|
||||
|
||||
- name: flush docker compose project setup
|
||||
- name: flush docker compose up
|
||||
meta: flush_handlers
|
||||
|
@@ -1,4 +1,5 @@
|
||||
# Base for docker services
|
||||
{# Base for docker services #}
|
||||
|
||||
restart: {{docker_restart_policy}}
|
||||
env_file:
|
||||
- "{{docker_compose.files.env}}"
|
||||
|
Reference in New Issue
Block a user