Skip to content

Commit

Permalink
feat: added healthcheck to outline (#469)
Browse files Browse the repository at this point in the history
* feat: added healthcheck to outline

* fix: remove redundant task

* fix: removed redundant Dockerfile thanks to outline patch

* fix: outline did not see .env file

* feat: define volume path

* fix: docker whined about syntax

* fix: docker image inconcistencies

* fix: confused ports
  • Loading branch information
SilasPeters authored Mar 4, 2025
1 parent 3f67d26 commit 96ea5cf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
11 changes: 9 additions & 2 deletions ansible/roles/docker/tasks/compose-up.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
# Possible variables which can be set to change the behaviour of these tasks:
# - project_source (required): the path to the directory the compose file is in
# - remove_images: whether to remove and rebuild all used images while composing up.
# Leave unset to keep the images, otherwise use "local" or "all"

- name: "Check if 'project_source' is defined"
ansible.builtin.fail:
Expand All @@ -21,6 +25,7 @@
community.docker.docker_compose_v2:
project_src: "{{ project_source }}"
state: "absent"
remove_images: "{{ remove_images | default(omit) }}" # NOTE: can give the warning that nothing is to be removed, if nothing exists yet (and thus expected)

- name: "Create and start services"
community.docker.docker_compose_v2:
Expand All @@ -36,7 +41,7 @@
project_src: "{{ project_source }}"
register: "output"

- name: "Assert that all services properly started"
- name: "Assert that all services properly started, and that the docker compose file is idempotent"
ansible.builtin.assert:
that: "not output.changed"

Expand Down Expand Up @@ -69,10 +74,12 @@
- "output.containers | selectattr('Name', 'equalto', item) | map(attribute='State') | list | first == 'exited'"
loop: "{{ docker_compose_service_names }}"

- name: "Restart services"
- name: "Restart services and ensure they are healhty"
community.docker.docker_compose_v2:
project_src: "{{ project_source }}"
state: "restarted"
wait: true
wait_timeout: 300
register: "output"

# - name: Show results
Expand Down
7 changes: 3 additions & 4 deletions ansible/roles/outline/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
mode: "0600"
notify: "trigger outline migration"

- name: "Create outline 'docker.env' file"
- name: "Create outline '.env' file"
ansible.builtin.template:
src: "docker.env.j2"
dest: "{{ outline_config.project_source }}/docker.env"
src: ".env.j2"
dest: "{{ outline_config.project_source }}/.env"
owner: "outline"
group: "outline"
mode: "0600"
Expand Down Expand Up @@ -76,7 +76,6 @@
path: "{{ outline_config.project_source }}/.MIGRATION_PENDING"
state: "absent"


- name: "Docker compose"
ansible.builtin.include_tasks: "../docker/tasks/compose-up.yml"
vars:
Expand Down
File renamed without changes.
19 changes: 14 additions & 5 deletions ansible/roles/outline/templates/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
services:

outline:
container_name: outline
image: outlinewiki/outline:{{ outline_config.version }}
restart: unless-stopped
env_file: ./docker.env
# ports:
# - "4568:3000"
network_mode: host # TODO replace this
env_file: .env
restart: always
network_mode: host # TODO replace this once postgres has been dockerized
# ports:
# - "4568:3000"
healthcheck:
test: |
wget -qO- http://localhost:${PORT}/_health | grep -q OK \
&& wget -qO- https://hc-ping.com/{{ secret_healthchecks_io.ping_key }}/outline \
|| exit 1
interval: 5m
start_period: 30s
start_interval: 10s
volumes:
- storage-data:/var/lib/outline/data
# depends_on:
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/outline/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

outline_config:
project_source: "/var/www/outline/outline"
version: "0.78.0"
version: "0.79.0" # Git tag

0 comments on commit 96ea5cf

Please sign in to comment.