From 1ca210608a92578a2cea24eb529a8460a2ff2927 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 16 Nov 2022 16:04:01 +0100 Subject: [PATCH] optimized mastodon and pixelfed implementation --- roles/docker-mastodon/tasks/main.yml | 5 +++- roles/docker-pixelfed/README.md | 5 ++++ roles/docker-pixelfed/tasks/main.yml | 27 ++++++++++--------- .../templates/docker-compose.yml.j2 | 4 +-- roles/docker-pixelfed/templates/env.j2 | 20 +++++++------- roles/docker-pixelfed/vars/main.yml | 1 + 6 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 roles/docker-pixelfed/vars/main.yml diff --git a/roles/docker-mastodon/tasks/main.yml b/roles/docker-mastodon/tasks/main.yml index d8f30616..b4b90a28 100644 --- a/roles/docker-mastodon/tasks/main.yml +++ b/roles/docker-mastodon/tasks/main.yml @@ -17,5 +17,8 @@ notify: recreate mastodon - name: copy configuration - template: src=.env.production.j2 dest={{docker_compose_mastodon_path}}.env.production + template: + src: .env.production.j2 + dest: "{{docker_compose_mastodon_path}}.env.production" + force: no notify: recreate mastodon diff --git a/roles/docker-pixelfed/README.md b/roles/docker-pixelfed/README.md index 38bc4d6f..35ae0a47 100644 --- a/roles/docker-pixelfed/README.md +++ b/roles/docker-pixelfed/README.md @@ -1,4 +1,9 @@ # role docker-pixelfed +## hard cleanup +```bash +docker-compose down +docker volume rm pixelfed_application_data pixelfed_database pixelfed_redis_data +``` ## further information - https://hub.docker.com/r/zknt/pixelfed diff --git a/roles/docker-pixelfed/tasks/main.yml b/roles/docker-pixelfed/tasks/main.yml index 87d75c2e..ffe5531c 100644 --- a/roles/docker-pixelfed/tasks/main.yml +++ b/roles/docker-pixelfed/tasks/main.yml @@ -1,22 +1,25 @@ --- -- name: recieve pixelfed certificates - command: certbot certonly --agree-tos --email {{administrator_email}} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{item}} - loop: "{{domains}}" +- name: recieve {{domain}} certificate + command: certbot certonly --agree-tos --email {{administrator_email}} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{domain}} -- name: configure pixelfed nginx configurations - vars: - client_max_body_size: "2M" - domain: "{{item}}" - template: src=roles/native-docker-reverse-proxy/templates/domain.conf.j2 dest=/etc/nginx/conf.d/{{ item }}.conf - loop: "{{domains}}" +- name: configure {{domain}}.conf + template: src=roles/native-docker-reverse-proxy/templates/domain.conf.j2 dest=/etc/nginx/conf.d/{{domain}}.conf notify: restart nginx -- name: "create /home/administrator/docker-compose/pixelfed/" +- name: "create {{docker_compose_path}}" file: - path: "/home/administrator/docker-compose/pixelfed/" + path: "{{docker_compose_path}}" state: directory mode: 0755 - name: add docker-compose.yml - template: src=docker-compose.yml.j2 dest=/home/administrator/docker-compose/pixelfed/docker-compose.yml + template: src=docker-compose.yml.j2 dest={{docker_compose_path}}docker-compose.yml notify: recreate pixelfed + +- name: add env + template: + src: env.j2 + dest: "{{docker_compose_path}}env" + mode: '770' + force: no + notify: recreate pixelfed \ No newline at end of file diff --git a/roles/docker-pixelfed/templates/docker-compose.yml.j2 b/roles/docker-pixelfed/templates/docker-compose.yml.j2 index e926d8da..72df6e12 100644 --- a/roles/docker-pixelfed/templates/docker-compose.yml.j2 +++ b/roles/docker-pixelfed/templates/docker-compose.yml.j2 @@ -30,7 +30,7 @@ services: depends_on: - database - redis - - app + - application healthcheck: test: php artisan horizon:status | grep running interval: 60s @@ -56,7 +56,7 @@ services: logging: driver: journald volumes: - - redis:/data + - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 1s diff --git a/roles/docker-pixelfed/templates/env.j2 b/roles/docker-pixelfed/templates/env.j2 index af0aa95e..c3cb65ce 100644 --- a/roles/docker-pixelfed/templates/env.j2 +++ b/roles/docker-pixelfed/templates/env.j2 @@ -1,8 +1,8 @@ ## Crypto -APP_KEY= +APP_KEY={{pixelfed_app_key}} ## General Settings -APP_NAME="Pixelfed Prod" +APP_NAME="Pixelfed on Veen.World" APP_ENV=production APP_DEBUG=false APP_URL=https://{{domain}} @@ -56,16 +56,12 @@ MAIL_ENCRYPTION=tls ## Databases (MySQL) DB_CONNECTION=mysql -DB_DATABASE=pixelfed_prod -DB_HOST=db -DB_PASSWORD=pixelfed_db_pass +DB_DATABASE=pixelfed +DB_HOST=database +DB_PASSWORD="{{pixelfed_database_password}}" DB_PORT=3306 DB_USERNAME=pixelfed # pass the same values to the db itself -MYSQL_DATABASE=pixelfed_prod -MYSQL_PASSWORD=pixelfed_db_pass -MYSQL_RANDOM_ROOT_PASSWORD=true -MYSQL_USER=pixelfed MYSQL_DATABASE="pixelfed" MYSQL_USER="pixelfed" MYSQL_PASSWORD="{{pixelfed_database_password}}" @@ -75,7 +71,7 @@ MYSQL_ROOT_PASSWORD="{{pixelfed_database_password}}" REDIS_CLIENT=phpredis REDIS_SCHEME=tcp REDIS_HOST=redis -REDIS_PASSWORD=redis_password +#REDIS_PASSWORD= REDIS_PORT=6379 REDIS_DATABASE=0 @@ -136,4 +132,6 @@ TRUST_PROXIES="*" ## Passport #PASSPORT_PRIVATE_KEY= -#PASSPORT_PUBLIC_KEY= \ No newline at end of file +#PASSPORT_PUBLIC_KEY= + +ENABLE_CONFIG_CACHE=true \ No newline at end of file diff --git a/roles/docker-pixelfed/vars/main.yml b/roles/docker-pixelfed/vars/main.yml new file mode 100644 index 00000000..7097d8dd --- /dev/null +++ b/roles/docker-pixelfed/vars/main.yml @@ -0,0 +1 @@ +docker_compose_path: "/home/administrator/docker-compose/pixelfed/"