# From https://github.com/mastodon/mastodon/blob/main/docker-compose.yml services: db: restart: always image: postgres:14-alpine shm_size: 256mb networks: - internal_network healthcheck: test: ["CMD", "pg_isready", "-U", "postgres"] volumes: - "{{ mastodon_docker_postgres_storage }}:/var/lib/postgresql/data" environment: - "POSTGRES_HOST_AUTH_METHOD=trust" - "POSTGRES_USER=mastodon" - "POSTGRES_DB=mastodon_production" redis: restart: always image: redis:7-alpine networks: - internal_network healthcheck: test: ["CMD", "redis-cli", "ping"] volumes: - "{{ mastodon_docker_redis_storage }}:/data" {% if mastodon_docker_enable_elasticsearch %} es: restart: always image: docker.elastic.co/elasticsearch/elasticsearch:7.17.29 environment: - "ES_JAVA_OPTS=-Xms512m -Xmx512m -Des.enforce.bootstrap.checks=true" - "xpack.license.self_generated.type=basic" - "xpack.security.enabled=false" - "xpack.watcher.enabled=false" - "xpack.graph.enabled=false" - "xpack.ml.enabled=false" - "bootstrap.memory_lock=true" - "cluster.name=es-mastodon" - "discovery.type=single-node" - "thread_pool.write.queue_size=1000" networks: - external_network - internal_network healthcheck: test: [ "CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1", ] volumes: - "{{mastodon_docker_elasticsearch_storage}}:/usr/share/elasticsearch/data" ulimits: memlock: soft: -1 hard: -1 nofile: soft: 65536 hard: 65536 {% endif %} web: build: . restart: always env_file: env command: bundle exec puma -C config/puma.rb networks: - external_network - internal_network healthcheck: # prettier-ignore test: ['CMD-SHELL',"curl -s --noproxy localhost localhost:3000/health | grep -q 'OK' || exit 1"] ports: - "127.0.0.1:{{ mastodon_docker_web_port }}:3000" depends_on: - db - redis {% if mastodon_docker_enable_elasticsearch %} - es {% endif %} volumes: - "{{ mastodon_docker_system_storage }}:/mastodon/public/system" - "{{ mastodon_docker_cache_storage }}:/opt/mastodon/public/system/cache" streaming: image: ghcr.io/mastodon/mastodon-streaming:v4.5.9 restart: always env_file: env command: node ./streaming/index.js networks: - external_network - internal_network healthcheck: # prettier-ignore test: ['CMD-SHELL', "curl -s --noproxy localhost localhost:4000/api/v1/streaming/health | grep -q 'OK' || exit 1"] ports: - "127.0.0.1:{{ mastodon_docker_streaming_port }}:4000" depends_on: - db - redis sidekiq: image: ghcr.io/mastodon/mastodon:v4.5.9 restart: always env_file: env command: bundle exec sidekiq depends_on: - db - redis networks: - external_network - internal_network volumes: - "{{ mastodon_docker_system_storage }}:/mastodon/public/system" - "{{ mastodon_docker_cache_storage }}:/opt/mastodon/public/system/cache" healthcheck: test: ["CMD-SHELL", "ps aux | grep '[s]idekiq\ 8' || false"] networks: external_network: internal_network: internal: true