Implemented vars, tasks and templates for central database setup until mastodon role

This commit is contained in:
2024-01-02 21:13:34 +01:00
parent 4e09fbd3fb
commit ab7ca07ac9
76 changed files with 431 additions and 467 deletions

View File

@@ -1,15 +1,18 @@
---
- name: include docker vars
include_vars: vars/docker-database-service.yml.j2
- name: create central database
include_role:
name: docker-{{database_type}}
when: enable_central_database | bool
- name: "include create-domains.yml"
include_tasks: create-domains.yml
loop: "{{ domains }}"
loop_control:
loop_var: domain
- name: create database in central Postgres
include_role:
name: docker-postgres
when: enable_central_database | bool
- name: "create {{docker_compose_instance_directory}}"
file:
path: "{{docker_compose_instance_directory}}"

View File

@@ -10,9 +10,11 @@ DB_PORT=5432
DB_NAME={{database_databasename}}
DB_USER={{database_username}}
DB_PASS={{database_password}}
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=
SMTP_SERVER={{system_email_host}}
SMTP_PORT={{system_email_smtp_port}}
SMTP_LOGIN={{system_email_username}}

View File

@@ -3,81 +3,63 @@ services:
{% include 'templates/docker-redis-service.yml.j2' %}
networks:
- internal_network
{% include 'templates/docker-{{ database_type }}-service.yml.j2' %}
web:
image: tootsuite/mastodon:{{version_mastodon}}
restart: always
env_file: .env.production
command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
networks:
- external_network
- internal_network
healthcheck:
# prettier-ignore
test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:3000/health || exit 1']
ports:
- "127.0.0.1:{{http_port}}:3000"
depends_on:
{% if not enable_central_database %}
- database
{% endif %}
- redis
{% include 'templates/docker-depends-on-central-database.yml.j2' %}
redis:
condition: service_healthy
volumes:
- data:/mastodon/public/system
logging:
driver: journald
{% include 'templates/docker-networks-for-container.yml.j2' %}
streaming:
image: tootsuite/mastodon:{{version_mastodon}}
restart: always
env_file: .env.production
command: node ./streaming
networks:
- external_network
- internal_network
healthcheck:
# prettier-ignore
test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1']
ports:
- "127.0.0.1:{{stream_port}}:4000"
depends_on:
{% if not enable_central_database %}
- database
{% endif %}
- redis
{% include 'templates/docker-depends-on-central-database.yml.j2' %}
redis:
condition: service_healthy
logging:
driver: journald
{% include 'templates/docker-networks-for-container.yml.j2' %}
sidekiq:
image: tootsuite/mastodon:{{version_mastodon}}
restart: always
env_file: .env.production
command: bundle exec sidekiq
depends_on:
{% if not enable_central_database %}
- database
{% endif %}
- redis
networks:
- external_network
- internal_network
{% include 'templates/docker-depends-on-central-database.yml.j2' %}
redis:
condition: service_healthy
volumes:
- data:/mastodon/public/system
healthcheck:
test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"]
logging:
driver: journald
{% if not enable_central_database %}
{% include 'templates/docker-postgres-service.yml.j2' %}
{% endif %}
{% include 'templates/docker-networks-for-container.yml.j2' %}
volumes:
{% if not enable_central_database %}
database:
{% endif %}
{% include 'templates/docker-database-volume.yml.j2' %}
redis:
data:
networks:
external_network:
internal_network:
internal: true
{% include 'templates/docker-networks-for-role.yml.j2' %}

View File

@@ -1,7 +1,4 @@
docker_compose_project_name: "mastodon"
docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/"
database_host: "database"
database_databasename: "{{docker_compose_project_name}}"
database_username: "{{docker_compose_project_name}}"
database_password: "{{mastodon_database_password}}"
database_version: "{{ mastodon_database_version | default(postgres_default_version) }}"
database_version: "{{ mastodon_database_version | default(postgres_default_version) }}"
database_type: "postgres"