From 5b06c55859ccd0dea593179b4002de08038bdbd1 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Sat, 8 Jul 2023 20:41:23 +0300 Subject: [PATCH] Use upstream docker-compose --- templates/docker-compose.yml.j2 | 159 ++++++++++++-------------------- 1 file changed, 58 insertions(+), 101 deletions(-) diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 index 72706f4..b720acc 100644 --- a/templates/docker-compose.yml.j2 +++ b/templates/docker-compose.yml.j2 @@ -1,30 +1,19 @@ version: '3' services: - postgresql: + db: restart: always image: postgres:14-alpine - env_file: env.production - shm_size: 256mb + shm_size: 256mb networks: - internal_network healthcheck: test: ['CMD', 'pg_isready', '-U', 'postgres'] volumes: - - postgresql:/var/lib/postgresql/data + - ./postgres14:/var/lib/postgresql/data environment: - 'POSTGRES_HOST_AUTH_METHOD=trust' -# pgbouncer: -# image: edoburu/pgbouncer:1.12.0 -# env_file: env.production -# depends_on: -# - postgresql -# healthcheck: -# test: ['CMD', 'pg_isready', '-h', 'localhost'] -# networks: -# - internal_network - tor: image: sirboops/tor networks: @@ -47,7 +36,7 @@ services: healthcheck: test: ['CMD', 'redis-cli', 'ping'] volumes: - - redis:/data + - ./redis:/data redis-volatile: image: redis:7-alpine @@ -57,109 +46,94 @@ services: networks: - internal_network {% if es_enabled %} - elasticsearch: - image: elasticsearch:{{ es_version | default('7.17.7') }} + es: restart: always - env_file: env.production + image: docker.elastic.co/elasticsearch/elasticsearch:7.17.4 environment: - - cluster.name=elasticsearch-mastodon - - discovery.type=single-node - - bootstrap.memory_lock=true - - xpack.security.enabled=true - - ingest.geoip.downloader.enabled=false + - "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: + - ./elasticsearch:/usr/share/elasticsearch/data ulimits: memlock: soft: -1 hard: -1 - healthcheck: - test: ["CMD-SHELL", "nc -z elasticsearch 9200"] - volumes: - - elasticsearch:/usr/share/elasticsearch/data - networks: - - internal_network + nofile: + soft: 65536 + hard: 65536 + ports: + - '127.0.0.1:9200:9200' + {% endif %} - website: + web: build: . - restart: always - #image: tootsuite/mastodon:latest image: ghcr.io/mastodon/mastodon - env_file: - - env.production - #command: bash -c "bundle exec rails s -p 3000" + 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:3000:3000' depends_on: - - postgresql -# - pgbouncer + - db - redis - - redis-volatile - - elasticsearch + # - es volumes: - - uploads:/mastodon/public/system - #- ./public/system:/mastodon/public/system - - shell: - image: tootsuite/mastodon:latest - env_file: - - env.production - command: /bin/bash - restart: "no" - networks: - - internal_network - - external_network - volumes: - - uploads:/mastodon/public/system + - ./public/system:/mastodon/public/system streaming: build: . image: ghcr.io/mastodon/mastodon - #image: tootsuite/mastodon:latest - env_file: - - env.production - command: node ./streaming restart: always - depends_on: - - postgresql -# - pgbouncer - - redis - - redis-volatile - - elasticsearch + 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:4000:4000' - networks: - - internal_network - - external_network - healthcheck: - test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1'] + depends_on: + - db + - redis sidekiq: build: . image: ghcr.io/mastodon/mastodon - #image: tootsuite/mastodon:latest - env_file: - - env.production - command: bundle exec sidekiq restart: always + env_file: .env.production + command: bundle exec sidekiq depends_on: - - postgresql -# - pgbouncer + - db - redis - - redis-volatile - - website networks: - - internal_network - external_network + - internal_network + volumes: + - ./public/system:/mastodon/public/system healthcheck: test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"] - volumes: - - uploads:/mastodon/public/system - #- ./public/system:/mastodon/public/system + networks: external_network: @@ -167,24 +141,7 @@ networks: internal_network: internal: true -volumes: - postgresql: - driver_opts: - type: none - device: {{ mastodon_composer_folder }}/database/postgresql - o: bind - redis: - driver_opts: - type: none - device: {{ mastodon_composer_folder }}/database/redis - o: bind -{% if es_enabled %} elasticsearch: - driver_opts: - type: none - device: {{ mastodon_composer_folder }}/database/elasticsearch - o: bind -{% endif %} uploads: - driver_opts: - type: none - device: {{ mastodon_composer_folder }}/web/system - o: bind +# networks: +# external_network: +# internal_network: +# internal: true