From fc55dc1c2829e98aa69b1fc3e7606cacfc21e211 Mon Sep 17 00:00:00 2001 From: l-m Date: Tue, 27 Oct 2026 10:57:09 +1100 Subject: [PATCH 1/2] add zenith compose and expose email as env vars --- Dockerfile | 2 +- README.md | 6 ++ config/environments/production.rb | 15 ++++- config/initializers/devise.rb | 2 +- zenith-compose.yml | 93 +++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 zenith-compose.yml diff --git a/Dockerfile b/Dockerfile index d4f9a3d5..cacf525c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ RUN crontab /etc/cron.d/feed-fetch-cron RUN touch /var/log/cron.log ADD . . -RUN bin/rails assets:precompile +RUN SECRET_KEY_BASE_DUMMY=1 bin/rails assets:precompile EXPOSE 3000 diff --git a/README.md b/README.md index 0baaf45d..62dc626e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ The following are some motivating philosophies: # Deployment +## Zenith + +[![Deploy with Zenith](https://cdn.zenith.hosting/buttons/deploy-with-zenith.svg)](https://zenith.hosting/host/haven) + +You can host Haven on Zenith without setting up or managing your own server. + ## PikaPods [![Run on PikaPods](https://www.pikapods.com/static/run-button.svg)](https://www.pikapods.com/pods?run=haven) diff --git a/config/environments/production.rb b/config/environments/production.rb index 8606f24d..1c3744a9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -61,7 +61,20 @@ # config.action_mailer.raise_delivery_errors = false # Set host to be used by links generated in mailer templates. - config.action_mailer.default_url_options = { host: "example.com" } + config.action_mailer.default_url_options = { host: ENV.fetch("HAVEN_PUBLIC_HOST", "example.com"), protocol: "https" } + + if ENV["HAVEN_SMTP_HOST"].present? + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: ENV.fetch("HAVEN_SMTP_HOST"), + port: Integer(ENV.fetch("HAVEN_SMTP_PORT", "587")), + user_name: ENV.fetch("HAVEN_SMTP_USER"), + password: ENV.fetch("HAVEN_SMTP_PASSWORD"), + authentication: :plain, + enable_starttls: true + } + config.action_mailer.default_options = { from: ENV.fetch("HAVEN_SMTP_FROM") } + end # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. # config.action_mailer.smtp_settings = { diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 60091ea0..e3149bdc 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -18,7 +18,7 @@ # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = "change-me-@example.com" + config.mailer_sender = ENV.fetch("HAVEN_SMTP_FROM", "change-me-@example.com") # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer' diff --git a/zenith-compose.yml b/zenith-compose.yml new file mode 100644 index 00000000..05db69fa --- /dev/null +++ b/zenith-compose.yml @@ -0,0 +1,93 @@ +services: + haven: + build: . + environment: + RAILS_ENV: production + HAVEN_DEPLOY: local + HAVEN_DB_HOST: postgresql + HAVEN_DB_NAME: haven + HAVEN_DB_ROLE: haven + volumes: + - haven_storage:/app/storage + depends_on: + postgresql: + condition: service_healthy + postgresql: + image: postgres:16-alpine + environment: + POSTGRES_DB: haven + POSTGRES_USER: haven + volumes: + - postgresqldata:/var/lib/postgresql/data + healthcheck: + test: [CMD-SHELL, "pg_isready -U haven -d haven"] + interval: 5s + timeout: 5s + retries: 12 + +volumes: + haven_storage: + postgresqldata: + +x-zenith: + catalog: + name: Haven + description: A private blog for sharing with friends and family, with a built-in RSS reader. + authors: [havenweb] + tags: [blogging, rss] + source: https://github.com/havenweb/haven + website: https://havenweb.org + license: MIT + expose: + - service: haven + port: 3000 + web: true + storage: + uploads: + volume: haven_storage + label: Private uploads + public: false + database: + volume: postgresqldata + label: PostgreSQL data + public: false + env: + SECRET_KEY_BASE: + generate: '[a-f0-9]{128}' + services: [haven] + HAVEN_DB_PASSWORD: + generate: '[A-Za-z0-9]{32}' + services: [haven] + POSTGRES_PASSWORD: + alias: HAVEN_DB_PASSWORD + services: [postgresql] + HAVEN_USER_EMAIL: + services: [haven] + input: + label: Initial admin email + default_template: '{ZENITH_OWNER_EMAIL}' + required: true + HAVEN_USER_PASS: + generate: '[A-Za-z0-9]{32}' + services: [haven] + input: + label: Initial admin password + secret: true + HAVEN_PUBLIC_HOST: + alias: ZENITH_PUBLIC_HOST + services: [haven] + HAVEN_SMTP_HOST: + alias: ZENITH_SMTP_HOST + services: [haven] + HAVEN_SMTP_PORT: + alias: ZENITH_SMTP_PORT + services: [haven] + HAVEN_SMTP_USER: + alias: ZENITH_SMTP_USER + services: [haven] + HAVEN_SMTP_PASSWORD: + alias: ZENITH_SMTP_PASS + services: [haven] + HAVEN_SMTP_FROM: + alias: ZENITH_SMTP_FROM + services: [haven] From 2e6ea38439fddf8d263718d3f42194221be5d324 Mon Sep 17 00:00:00 2001 From: l-m Date: Wed, 28 Oct 2026 11:56:38 +1100 Subject: [PATCH 2/2] remove smtp env vars from zenith compose and config --- config/environments/production.rb | 15 +-------------- config/initializers/devise.rb | 2 +- zenith-compose.yml | 18 ------------------ 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 1c3744a9..8606f24d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -61,20 +61,7 @@ # config.action_mailer.raise_delivery_errors = false # Set host to be used by links generated in mailer templates. - config.action_mailer.default_url_options = { host: ENV.fetch("HAVEN_PUBLIC_HOST", "example.com"), protocol: "https" } - - if ENV["HAVEN_SMTP_HOST"].present? - config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { - address: ENV.fetch("HAVEN_SMTP_HOST"), - port: Integer(ENV.fetch("HAVEN_SMTP_PORT", "587")), - user_name: ENV.fetch("HAVEN_SMTP_USER"), - password: ENV.fetch("HAVEN_SMTP_PASSWORD"), - authentication: :plain, - enable_starttls: true - } - config.action_mailer.default_options = { from: ENV.fetch("HAVEN_SMTP_FROM") } - end + config.action_mailer.default_url_options = { host: "example.com" } # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. # config.action_mailer.smtp_settings = { diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index e3149bdc..60091ea0 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -18,7 +18,7 @@ # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = ENV.fetch("HAVEN_SMTP_FROM", "change-me-@example.com") + config.mailer_sender = "change-me-@example.com" # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer' diff --git a/zenith-compose.yml b/zenith-compose.yml index 05db69fa..e5f3fc0f 100644 --- a/zenith-compose.yml +++ b/zenith-compose.yml @@ -73,21 +73,3 @@ x-zenith: input: label: Initial admin password secret: true - HAVEN_PUBLIC_HOST: - alias: ZENITH_PUBLIC_HOST - services: [haven] - HAVEN_SMTP_HOST: - alias: ZENITH_SMTP_HOST - services: [haven] - HAVEN_SMTP_PORT: - alias: ZENITH_SMTP_PORT - services: [haven] - HAVEN_SMTP_USER: - alias: ZENITH_SMTP_USER - services: [haven] - HAVEN_SMTP_PASSWORD: - alias: ZENITH_SMTP_PASS - services: [haven] - HAVEN_SMTP_FROM: - alias: ZENITH_SMTP_FROM - services: [haven]