Saibotk
58a1f63a8e
BREAKING! Requires these new secrets to be set: mastodon_config: ar_enc_deterministic_key: undef ar_enc_derivation_salt: undef ar_enc_primary_key: undef
179 lines
5.5 KiB
YAML
179 lines
5.5 KiB
YAML
{{ ansible_managed | comment }}
|
|
|
|
# Infrastructure
|
|
# Ansible instructions to deploy the infrastructure
|
|
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
|
|
# Copyright (C) 2020 Saibotk
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, version 3 of the License.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
version: '2.1'
|
|
services:
|
|
nginx:
|
|
image: docker.io/library/nginx:alpine
|
|
mem_limit: 32mb
|
|
memswap_limit: 64mb
|
|
labels:
|
|
- "traefik.http.routers.mastodon.rule=Host(`{{ mastodon_domain }}`) && PathPrefix(`/`)"
|
|
- "traefik.http.routers.mastodon.entrypoints=websecure"
|
|
- "traefik.http.routers.mastodon.tls.certresolver={{ mastodon_traefik_certresolver }}"
|
|
- "traefik.http.routers.mastodon.middlewares=mastodon,compress"
|
|
- "traefik.http.middlewares.mastodon.headers.sslredirect=true"
|
|
- "traefik.http.middlewares.mastodon.headers.stsSeconds=63072000"
|
|
- "traefik.http.middlewares.mastodon.headers.referrerPolicy=same-origin"
|
|
|
|
- "traefik.enable=true"
|
|
{% if proxy_network is defined %}
|
|
- "traefik.docker.network={{ proxy_network }}"
|
|
{% endif %}
|
|
networks:
|
|
frontend:
|
|
{% if proxy_network is defined %}
|
|
{{ proxy_network }}:
|
|
{% endif %}
|
|
volumes:
|
|
- "{{ mastodon_nginx_location }}/default.conf:/etc/nginx/conf.d/default.conf:ro"
|
|
- "{{ mastodon_public_location }}:/usr/share/nginx/html:ro"
|
|
depends_on:
|
|
- web
|
|
- streaming
|
|
restart: always
|
|
|
|
db:
|
|
image: docker.io/library/postgres:{{ mastodon_database_image_version }}
|
|
mem_limit: 512mb
|
|
memswap_limit: 768mb
|
|
read_only: true
|
|
tmpfs:
|
|
- /run/postgresql:size=512K
|
|
- /tmp:size=128K
|
|
environment:
|
|
- "POSTGRES_HOST_AUTH_METHOD=trust"
|
|
stop_grace_period: 2m
|
|
stop_signal: SIGINT
|
|
networks:
|
|
backend:
|
|
healthcheck:
|
|
test: ['CMD', 'pg_isready', '-U', 'postgres']
|
|
volumes:
|
|
- {{ mastodon_database_location }}:/var/lib/postgresql/data
|
|
restart: always
|
|
|
|
redis:
|
|
image: docker.io/library/redis:{{ mastodon_redis_image_version }}
|
|
mem_limit: 512mb
|
|
memswap_limit: 768mb
|
|
networks:
|
|
backend:
|
|
healthcheck:
|
|
test: ['CMD', 'redis-cli', 'ping']
|
|
volumes:
|
|
- {{ mastodon_redis_location }}:/data
|
|
restart: always
|
|
|
|
{% if mastodon_config.enable_elasticsearch is defined and mastodon_config.enable_elasticsearch %}
|
|
es:
|
|
restart: always
|
|
image: docker.elastic.co/elasticsearch/elasticsearch:{{ mastodon_elasticsearch_image_version }}
|
|
mem_limit: 1124mb
|
|
memswap_limit: 1280mb
|
|
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"
|
|
- "ingest.geoip.downloader.enabled=false"
|
|
networks:
|
|
backend:
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
|
|
ulimits:
|
|
memlock:
|
|
soft: -1
|
|
hard: -1
|
|
nofile:
|
|
soft: 65536
|
|
hard: 65536
|
|
volumes:
|
|
- {{ mastodon_elastic_location }}:/usr/share/elasticsearch/data
|
|
{% endif %}
|
|
|
|
web:
|
|
image: ghcr.io/mastodon/mastodon:{{ mastodon_image_version }}
|
|
mem_limit: 1024mb
|
|
memswap_limit: 1280mb
|
|
env_file: {{ mastodon_install_location }}/.env.production
|
|
depends_on:
|
|
- db
|
|
- redis
|
|
{% if mastodon_config.enable_elasticsearch is defined and mastodon_config.enable_elasticsearch %}
|
|
- es
|
|
{% endif %}
|
|
volumes:
|
|
- {{ mastodon_public_location }}/system:/mastodon/public/system
|
|
networks:
|
|
frontend:
|
|
backend:
|
|
healthcheck:
|
|
test: ['CMD-SHELL',"curl -s --noproxy localhost localhost:3000/health | grep -q 'OK' || exit 1"]
|
|
restart: always
|
|
command: bundle exec puma -C config/puma.rb
|
|
|
|
streaming:
|
|
image: ghcr.io/mastodon/mastodon-streaming:{{ mastodon_image_version }}
|
|
mem_limit: 1024mb
|
|
memswap_limit: 1280mb
|
|
env_file: {{ mastodon_install_location }}/.env.production
|
|
networks:
|
|
frontend:
|
|
backend:
|
|
healthcheck:
|
|
test: ['CMD-SHELL', "curl -s --noproxy localhost localhost:4000/api/v1/streaming/health | grep -q 'OK' || exit 1"]
|
|
depends_on:
|
|
- db
|
|
- redis
|
|
restart: always
|
|
command: node ./streaming/index.js
|
|
|
|
sidekiq:
|
|
image: ghcr.io/mastodon/mastodon:{{ mastodon_image_version }}
|
|
mem_limit: 1024mb
|
|
memswap_limit: 1280mb
|
|
env_file: {{ mastodon_install_location }}/.env.production
|
|
depends_on:
|
|
- db
|
|
- redis
|
|
volumes:
|
|
- {{ mastodon_public_location }}/system:/mastodon/public/system
|
|
networks:
|
|
frontend:
|
|
backend:
|
|
healthcheck:
|
|
test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"]
|
|
restart: always
|
|
command: bundle exec sidekiq
|
|
|
|
networks:
|
|
frontend:
|
|
backend:
|
|
internal: true
|
|
{% if proxy_network is defined %}
|
|
{{ proxy_network }}:
|
|
external: true
|
|
{% endif %}
|