diff --git a/tasks/docker/docker.yml b/tasks/docker/docker.yml index e6acf64..e36e809 100644 --- a/tasks/docker/docker.yml +++ b/tasks/docker/docker.yml @@ -73,16 +73,10 @@ src: templates/docker-compose.yml.j2 dest: "{{ mastodon_composer_folder }}/docker-compose.yml" -- name: Ensure mastodon application configuration is present +- name: Ensure mastodon environment configuration is present template: - src: templates/application.env.j2 - dest: "{{ mastodon_composer_folder }}/application.env.production" - mode: 0600 - -- name: Ensure mastodon database configuration is present - template: - src: templates/database.env.j2 - dest: "{{ mastodon_composer_folder }}/database.env.production" + src: templates/env.j2 + dest: "{{ mastodon_composer_folder }}/env.production" mode: 0600 - name: Generate secret key @@ -99,7 +93,7 @@ - name: Add secret key to Mastodon config lineinfile: - path: "{{ mastodon_composer_folder }}/application.env.production" + path: "{{ mastodon_composer_folder }}/env.production" line: "SECRET_KEY_BASE={{ mastodon_secret_key_base }}" regexp: "^SECRET_KEY_BASE=" backup: yes @@ -119,7 +113,7 @@ - name: Add OTP key to Mastodon config lineinfile: - path: "{{ mastodon_composer_folder }}/application.env.production" + path: "{{ mastodon_composer_folder }}/env.production" line: "OTP_SECRET={{ mastodon_otp_secret }}" regexp: "^OTP_SECRET=" backup: yes @@ -139,7 +133,7 @@ - name: Add Paperclip key to Mastodon config lineinfile: - path: "{{ mastodon_composer_folder }}/application.env.production" + path: "{{ mastodon_composer_folder }}/env.production" line: "PAPERCLIP_SECRET={{ mastodon_paperclip_secret }}" regexp: "^PAPERCLIP_SECRET=" backup: yes @@ -164,7 +158,7 @@ - name: Add Paperclip private key to Mastodon config lineinfile: - path: "{{ mastodon_composer_folder }}/application.env.production" + path: "{{ mastodon_composer_folder }}/env.production" line: "{{ vapid_private_key }}" regexp: "^VAPID_PRIVATE_KEY=" mode: 0600 @@ -172,7 +166,7 @@ - name: Add Paperclip public key to Mastodon config lineinfile: - path: "{{ mastodon_composer_folder }}/application.env.production" + path: "{{ mastodon_composer_folder }}/env.production" line: "{{ vapid_public_key }}" regexp: "^VAPID_PUBLIC_KEY=" mode: 0600 diff --git a/templates/database.env.j2 b/templates/database.env.j2 deleted file mode 100644 index 48d8dca..0000000 --- a/templates/database.env.j2 +++ /dev/null @@ -1,34 +0,0 @@ -# postgresql configuration -POSTGRES_USER={{ mastodon_db_user }} -POSTGRES_DB={{ mastodon_db }} -POSTGRES_PASSWORD={{ mastodon_db_password }} - -# pgbouncer configuration -#POOL_MODE=transaction -#ADMIN_USERS=postgres,mastodon -#DATABASE_URL="postgres://mastodon:O6lOD6nF2LbhhJs1e7QL@postgresql:5432/mastodon_production" - -# elasticsearch -ES_JAVA_OPTS=-Xms512m -Xmx512m -ELASTIC_PASSWORD={{ es_pass }} - -# mastodon database configuration -#DB_HOST=pgbouncer -DB_HOST={{ mastodon_db_login_unix_socket }} -DB_USER={{ mastodon_db_user }} -DB_NAME={{ mastodon_db }} -DB_PASS={{ mastodon_db_password }} -DB_PORT=5432 - -REDIS_HOST={{ redis_host }} -REDIS_PORT={{ redis_port }} - -CACHE_REDIS_HOST=redis-volatile -CACHE_REDIS_PORT=6379 - -ES_ENABLED={{ es_enabled }} -ES_HOST={{ es_host }} -ES_PORT={{ es_port }} -# Authentication for ES (optional) -ES_USER={{ es_user }} -ES_PASS={{ es_pass }} diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 index c8d75e9..c3e23b6 100644 --- a/templates/docker-compose.yml.j2 +++ b/templates/docker-compose.yml.j2 @@ -3,7 +3,7 @@ version: '3' services: postgresql: image: postgres:14-alpine - env_file: database.env.production + env_file: env.production restart: always shm_size: 256mb healthcheck: @@ -15,7 +15,7 @@ services: # pgbouncer: # image: edoburu/pgbouncer:1.12.0 -# env_file: database.env.production +# env_file: env.production # depends_on: # - postgresql # healthcheck: @@ -44,7 +44,7 @@ services: elasticsearch: image: elasticsearch:{{ es_version | default('7.17.7') }} restart: always - env_file: database.env.production + env_file: env.production environment: - cluster.name=elasticsearch-mastodon - discovery.type=single-node @@ -65,8 +65,8 @@ services: website: image: tootsuite/mastodon:latest env_file: - - application.env.production - - database.env.production + - env.production + - env.production command: bash -c "bundle exec rails s -p 3000" restart: always depends_on: @@ -88,8 +88,8 @@ services: shell: image: tootsuite/mastodon:latest env_file: - - application.env.production - - database.env.production + - env.production + - env.production command: /bin/bash restart: "no" networks: @@ -101,8 +101,8 @@ services: streaming: image: tootsuite/mastodon:latest env_file: - - application.env.production - - database.env.production + - env.production + - env.production command: node ./streaming restart: always depends_on: @@ -122,8 +122,8 @@ services: sidekiq: image: tootsuite/mastodon:latest env_file: - - application.env.production - - database.env.production + - env.production + - env.production command: bundle exec sidekiq restart: always depends_on: diff --git a/templates/application.env.j2 b/templates/env.j2 similarity index 54% rename from templates/application.env.j2 rename to templates/env.j2 index 619718c..f4618e9 100644 --- a/templates/application.env.j2 +++ b/templates/env.j2 @@ -43,3 +43,39 @@ OTP_SECRET= VAPID_PRIVATE_KEY= VAPID_PUBLIC_KEY= + + +# postgresql configuration +POSTGRES_USER={{ mastodon_db_user }} +POSTGRES_DB={{ mastodon_db }} +POSTGRES_PASSWORD={{ mastodon_db_password }} + +# pgbouncer configuration +#POOL_MODE=transaction +#ADMIN_USERS=postgres,mastodon +#DATABASE_URL="postgres://mastodon:O6lOD6nF2LbhhJs1e7QL@postgresql:5432/mastodon_production" + +# elasticsearch +ES_JAVA_OPTS=-Xms512m -Xmx512m +ELASTIC_PASSWORD={{ es_pass }} + +# mastodon database configuration +#DB_HOST=pgbouncer +DB_HOST={{ mastodon_db_login_unix_socket }} +DB_USER={{ mastodon_db_user }} +DB_NAME={{ mastodon_db }} +DB_PASS={{ mastodon_db_password }} +DB_PORT=5432 + +REDIS_HOST={{ redis_host }} +REDIS_PORT={{ redis_port }} + +CACHE_REDIS_HOST=redis-volatile +CACHE_REDIS_PORT=6379 + +ES_ENABLED={{ es_enabled }} +ES_HOST={{ es_host }} +ES_PORT={{ es_port }} +# Authentication for ES (optional) +ES_USER={{ es_user }} +ES_PASS={{ es_pass }}