ansible/roles/docker/tasks/services/mastodon.yml

127 lines
3.9 KiB
YAML
Raw Permalink Normal View History

2022-11-26 08:52:41 +00:00
---
2022-05-07 20:53:18 +00:00
- name: create mastodon volume folders
2022-11-26 08:52:41 +00:00
ansible.builtin.file:
name: '{{ services.mastodon.volume_folder }}/{{ volume }}'
2022-05-07 20:53:18 +00:00
state: directory
2022-11-26 08:52:41 +00:00
owner: '991'
group: '991'
2022-05-07 20:53:18 +00:00
loop:
2022-11-26 08:52:41 +00:00
- postgres_data
- redis_data
- mastodon_data
2022-05-07 20:53:18 +00:00
loop_control:
loop_var: volume
- name: Copy mastodon environment file
2022-11-26 08:52:41 +00:00
ansible.builtin.template:
2022-05-07 20:53:18 +00:00
src: files/configs/mastodon/env_file.j2
2022-11-26 08:52:41 +00:00
dest: '{{ services.mastodon.volume_folder }}/env_file'
2022-05-07 20:53:18 +00:00
- name: upload vhost config for root domain
2022-11-26 08:52:41 +00:00
ansible.builtin.template:
2022-05-07 20:53:18 +00:00
src: files/configs/mastodon/vhost-mastodon
2022-11-26 08:52:41 +00:00
dest: '{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.mastodon.domain
}}'
2022-05-07 20:53:18 +00:00
- name: set up mastodon
2022-11-26 08:52:41 +00:00
community.docker.docker_compose:
2022-05-07 20:53:18 +00:00
project_name: mastodon
2022-11-26 08:52:41 +00:00
pull: true
2022-05-07 20:53:18 +00:00
definition:
version: '3'
services:
db:
restart: always
image: postgres:14-alpine
shm_size: 256mb
networks:
- internal_network
healthcheck:
2022-11-26 08:52:41 +00:00
test: [CMD, pg_isready, -U, postgres]
2022-05-07 20:53:18 +00:00
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mastodon.volume_folder }}/postgres_data:/var/lib/postgresql/data'
2022-05-07 20:53:18 +00:00
environment:
2022-11-26 08:52:41 +00:00
- POSTGRES_HOST_AUTH_METHOD=trust
2022-05-07 20:53:18 +00:00
redis:
restart: always
image: redis:6-alpine
networks:
- internal_network
healthcheck:
2022-11-26 08:52:41 +00:00
test: [CMD, redis-cli, ping]
2022-05-07 20:53:18 +00:00
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mastodon.volume_folder }}/redis_data:/data'
2022-05-07 20:53:18 +00:00
web:
2022-11-26 08:52:41 +00:00
image: tootsuite/mastodon:{{ services.mastodon.version }}
2022-05-07 20:53:18 +00:00
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mastodon.volume_folder }}/env_file'
command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails
s -p 3000"
2022-05-07 20:53:18 +00:00
networks:
- external_services
- internal_network
healthcheck:
2022-11-26 08:52:41 +00:00
test: |
[CMD-SHELL, wget -q --spider --proxy=off localhost:3000/health || exit 1]
2022-05-07 20:53:18 +00:00
depends_on:
- db
- redis
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mastodon.volume_folder }}/mastodon_data:/mastodon/public/system'
2022-05-07 20:53:18 +00:00
environment:
2022-11-26 08:52:41 +00:00
VIRTUAL_HOST: '{{ services.mastodon.domain }}'
VIRTUAL_PORT: '3000'
VIRTUAL_PATH: /
LETSENCRYPT_HOST: '{{ services.mastodon.domain }}'
LETSENCRYPT_EMAIL: '{{ letsencrypt_email }}'
2022-05-07 20:53:18 +00:00
streaming:
2022-11-26 08:52:41 +00:00
image: tootsuite/mastodon:{{ services.mastodon.version }}
2022-05-07 20:53:18 +00:00
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mastodon.volume_folder }}/env_file'
2022-05-07 20:53:18 +00:00
command: node ./streaming
networks:
- external_services
- internal_network
healthcheck:
2022-11-26 08:52:41 +00:00
test: |
[CMD-SHELL, wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1]
2022-05-07 20:53:18 +00:00
ports:
2022-11-26 08:52:41 +00:00
- 127.0.0.1:4000:4000
2022-05-07 20:53:18 +00:00
depends_on:
- db
- redis
environment:
2022-11-26 08:52:41 +00:00
VIRTUAL_HOST: '{{ services.mastodon.domain }}'
VIRTUAL_PORT: '4000'
VIRTUAL_PATH: /api/v1/streaming
2022-05-07 20:53:18 +00:00
sidekiq:
2022-11-26 08:52:41 +00:00
image: tootsuite/mastodon:{{ services.mastodon.version }}
2022-05-07 20:53:18 +00:00
restart: always
2022-11-26 08:52:41 +00:00
env_file: '{{ services.mastodon.volume_folder }}/env_file'
2022-11-22 08:36:36 +00:00
command: bundle exec sidekiq -c 32
environment:
DB_POOL: 32
2022-05-07 20:53:18 +00:00
depends_on:
- db
- redis
networks:
- postfix
- external_services
- internal_network
volumes:
2022-11-26 08:52:41 +00:00
- '{{ services.mastodon.volume_folder }}/mastodon_data:/mastodon/public/system'
2022-05-07 20:53:18 +00:00
healthcheck:
2022-11-26 08:52:41 +00:00
test: [CMD-SHELL, "ps aux | grep '[s]idekiq 6' || false"]
2022-05-07 20:53:18 +00:00
networks:
external_services:
external: true
postfix:
external: true
internal_network:
2022-11-26 08:52:41 +00:00
internal: true