docusealco / docuseal

Open source DocuSign alternative. Create, fill, and sign digital documents ✍️
https://www.docuseal.co
GNU Affero General Public License v3.0
5.97k stars 410 forks source link

SMTP setup via env variables or encrypted config? #113

Closed nebulade closed 11 months ago

nebulade commented 11 months ago

Hi, I am looking into packaging docuseal for Cloudron and mostly it works, besides the email/smtp config. My first question here is around how docuseal picks configuration values.

The package code exports the relevant STMP settings via env variables: https://git.cloudron.io/cloudron/docuseal-app/-/blob/main/start.sh?ref_type=heads#L8

Those seem to be picked up but are not shown in the settings UI. I guess those are thus never put into the settings db (encrypted config), which as such is good, as they can then presumably be updated on app restart if the env varibales change.

Is my observation correct here and is there any way then to prohibit showing the mail settings in the config UI to ensure a user will not overwrite those?

AlexandrToorchyn commented 11 months ago

Hi @nebulade i think it would be best to have users configure SMTP via the settings UI instead of the ENV variables to make the installation process easier for everyone. There is only one required ENV variable - SECRET_KEY_BASE (rails encryption key). DATABASE_URL can be used to point the app to PG database - but if not specified it will run in an Sqlite DB.

Let me know if that makes sense or if you need SMTP via env for some particular reason

AlexandrToorchyn commented 11 months ago

UPDATE: I spent some time to look how cloudron apps work and it seems like they all can share the same SMTP settings - in this case configuring SMTP via ENV makes sense and actually it will be easier for users to have it configured this way instead of the settings UI.

When SMTP is configured via ENV the smtp settings UI is still displayed - but the form is empty and those values are not copied into DB (which is probably good for the users).

I've just added a commit to hide smtp settings from the UI when env variables are used. Will be released in the next version today.

nebulade commented 11 months ago

Thanks for the fast response! Great to have that change then and thanks for the clarification on how it works. And yes in Cloudron the SMTP settings are provided by the platform into the app to avoid having the user to configure those for each app, so with your change this will work very well.

Besides that, there is still some things for me to work out on how to set this up. Sending an email results in the following resolving issue, but this may just be a quirk in Cloudron then. I am not a rails expert, so have to read up.

15:43:51 - E, [2023-09-24T13:43:51.420970 #8] ERROR -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [2d08cbfe-77a7-46d8-a93e-11a596e0fcd9] Error performing ActionMailer::MailDeliveryJob (Job ID: 2d08cbfe-77a7-46d8-a93e-11a596e0fcd9) from Async(default) in 133.84ms: SocketError (getaddrinfo: Name or service not known):
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:231:in `getaddrinfo'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:231:in `foreach'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:635:in `tcp'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:643:in `tcp_socket'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:656:in `do_start'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:611:in `start'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/message.rb:269:in `deliver!'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionmailer-7.0.7/lib/action_mailer/message_delivery.rb:109:in `block in deliver_now!'
......
AlexandrToorchyn commented 11 months ago

https://git.cloudron.io/cloudron/docuseal-app/-/blob/main/start.sh?ref_type=heads#L8

@nebulade based on the start.sh file it seems like you pass FROM address (email) into the SMTP_ADDRESS docuseal env variable - this variable should contain a DNS name of the host or IP address of the SMTP server (that's why you receive getaddrinfo: Name or service not know error)

Replacing it with CLOUDRON_MAIL_SMTP_SERVER should fix the error

nebulade commented 11 months ago

Ah thanks for the second pair of eyes. I've set now the correct env variable with email sending success and can confirm that the email settings view is also neatly disabled if env vars are set. Looks like I can release a Cloudron package for our users then tomorrow. Great app!

AlexandrToorchyn commented 11 months ago

Thanks! appreciate your effort on making DocuSeal available on Cloudron

On Sep 24 2023, at 11:00 pm, Johannes Zellner @.***> wrote:

Ah thanks for the second pair of eyes. I've set now the correct env variable with email sending success and can confirm that the email settings view is also neatly disabled if env vars are set. Looks like I can release a Cloudron package for our users then tomorrow. Great app! — Reply to this email directly, view it on GitHub (https://github.com/docusealco/docuseal/issues/113#issuecomment-1732656836), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AAI7GLZUFWTXOCKO5W3EOPTX4CGMJANCNFSM6AAAAAA5E6MZE4). You are receiving this because you commented.

nebulade commented 11 months ago

Just for reference, the initial app package is now available for Cloudron users. Great app!

omohokcoj commented 2 months ago

Hi @nebulade the latest 1.6.2 version introduces a new dependency - redis-server, which should be installed here: https://git.cloudron.io/cloudron/docuseal-app/-/blob/main/Dockerfile?ref_type=heads#L10