ansible-role-docker_mastodon/templates/docker-compose.yml

95 lines
3 KiB
YAML

# {{ ansible_managed }}
services:
db:
restart: always
image: postgres:14
shm_size: 256mb
networks:
- mastodon
healthcheck:
test: ['CMD', 'pg_isready', '-U', 'postgres']
volumes:
- {{ docker_mastodon_data_dir }}/{{ docker_mastodon_service_id }}/db_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: "{{ docker_mastodon_db_name }}"
POSTGRES_USER: "{{ docker_mastodon_db_user }}"
POSTGRES_PASSWORD: "{{ docker_mastodon_db_password }}"
redis:
restart: always
image: redis:6-alpine
networks:
- mastodon
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
volumes:
- {{ docker_mastodon_data_dir }}/{{ docker_mastodon_service_id }}/redis_data:/data
web:
image: tootsuite/mastodon:{{ docker_mastodon_image_version }}
restart: always
env_file: .env.production
command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
networks:
- traefik
- mastodon
healthcheck:
# prettier-ignore
test: ['CMD-SHELL',"curl -s --noproxy localhost localhost:3000/health | grep -q 'OK' || exit 1"]
depends_on:
- db
- redis
- streaming
- sidekiq
volumes:
- {{ docker_mastodon_data_dir }}/{{ docker_mastodon_service_id }}/mastodon_public_system:/mastodon/public/system
labels:
- traefik.enable=true
- traefik.docker.network=traefik
- traefik.http.routers.{{ docker_mastodon_service_id }}.entrypoints=web
- traefik.http.routers.{{ docker_mastodon_service_id }}.rule=Host(`{{ docker_mastodon_fqdn }}`)
- traefik.http.services.{{ docker_mastodon_service_id }}.loadbalancer.server.port=3000
streaming:
image: tootsuite/mastodon-streaming:{{ docker_mastodon_image_version }}
restart: always
env_file: .env.production
command: node ./streaming/index.js
networks:
- traefik
- mastodon
healthcheck:
# prettier-ignore
test: ['CMD-SHELL', "curl -s --noproxy localhost localhost:4000/api/v1/streaming/health | grep -q 'OK' || exit 1"]
labels:
- traefik.enable=true
- traefik.docker.network=traefik
- traefik.http.routers.{{ docker_mastodon_service_id }}-streaming.entrypoints=web
- traefik.http.routers.{{ docker_mastodon_service_id }}-streaming.rule=Host(`{{ docker_mastodon_fqdn }}`) && PathPrefix(`/api/v1/streaming`)
- traefik.http.services.{{ docker_mastodon_service_id }}-streaming.loadbalancer.server.port=4000
depends_on:
- db
- redis
sidekiq:
image: tootsuite/mastodon:{{ docker_mastodon_image_version }}
restart: always
env_file: .env.production
command: bundle exec sidekiq
depends_on:
- db
- redis
networks:
- traefik
- mastodon
volumes:
- {{ docker_mastodon_data_dir }}/{{ docker_mastodon_service_id }}/mastodon_public_system:/mastodon/public/system
healthcheck:
test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"]
networks:
traefik:
external: true
mastodon:
internal: true