badsyntax / dokku-discourse

Dokku plugin to manage discourse on your dokku server
MIT License
18 stars 8 forks source link

Setting up a new discourse instance seems to fail #15

Open rsmithlal opened 3 years ago

rsmithlal commented 3 years ago

After running the dokku discourse:create app-name command and filling in all of the prompted env vars, the new dokku app is created but none of the ENV vars that I provided values for are set in the app. Also, the app is never built and deployed. Am I supposed to be deploying a discourse repo as per normal dokku app procedure? Am I missing something? I followed the instructions in the readme, but coming up short. I hope that you can help.

badsyntax commented 3 years ago

Could possibly be due to a dokku update. Can you let me know what dokku version you're using?

rsmithlal commented 3 years ago

I'm using dokku version 0.23.7. I just recently installed dokku on a new debian server following the official dokku install instructions. Everything else with the dokku platform is working as expected. I'm going to turn on trace mode and see if I can learn more about what's happening.

rsmithlal commented 3 years ago

I'm running version 0.2.3 of the dokku-discourse plugin, and I installed it following the directions in the repo readme.

After entering the SMTP password at the last user prompt, this is what I get from the trace log (values changed for privacy):

+ local APP_STORAGE_ROOT=/var/lib/dokku/data/storage/app-name
+ fn-update-discourse-container-config app-name /var/lib/dokku/data/storage/app-name discourse.hostname.com developer-email@domain.com smtp.url.com 465 apikey api-password
+ declare APP_NAME=app-name APP_STORAGE_ROOT=/var/lib/dokku/data/storage/app-name HOSTNAME=discourse.hostname.com DEVELOPER_EMAILS=developer-email@domain.com SMTP_ADDRESS=smtp.url.com SMTP_PORT=465 SMTP_USER_NAME=apikey SMTP_PASSWORD=api-password
+ fn-update-discourse-config-env app-name discourse.hostname.com developer-email@domain.com smtp.url.com 465 apikey api-password
+ declare APP_NAME=app-name HOSTNAME=discourse.hostname.com DEVELOPER_EMAILS=developer-email@domain.com SMTP_ADDRESS=smtp.url.com SMTP_PORT=465 SMTP_USER_NAME=apikey SMTP_PASSWORD=api-password
+ local CONFIG_FILE_PATH=/home/dokku/app-name/discourse_standalone.yml
+ local UPDATE_ENV_BIN_PATH=/var/lib/dokku/plugins/available/discourse/containers/update-env
+ local UPDATED_CONFIG
++ /var/lib/dokku/plugins/available/discourse/containers/update-env /home/dokku/app-name/discourse_standalone.yml discourse.hostname.com developer-email@domain.com smtp.url.com 465 apikey api-password
+ UPDATED_CONFIG=

The contents of the discourse_standalone.yml file after the discourse:create command runs is as follows:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
params:
  db_default_text_search_config: "pg_catalog.english"
env:
  LANG: en_US.UTF-8
  DISCOURSE_DEFAULT_LOCALE: en
  DISCOURSE_HOSTNAME: 'discourse.dokku.me'
  DISCOURSE_DEVELOPER_EMAILS: 'me@example.com,you@example.com'
  DISCOURSE_SMTP_ADDRESS: smtp.example.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: user@example.com
  DISCOURSE_SMTP_PASSWORD: pa$$word
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
run:
  - exec: echo "Beginning of custom commands"
  - exec: echo "End of custom commands"

After I originally ran the create command and this didn't work, I tried to manually change the values in the discourse_standalone.yml file and that didn't seem to make a difference and was overwritten when I ran the create command a second time.

There were no ENV vars set in for the dokku app after the create command was run. The result of running dokku config:show app-name is empty.

I hope this information can help diagnose what's going on!

rsmithlal commented 3 years ago

@badsyntax any ideas for what could be wrong or a potential fix? I'd really like to use your plugin to create and manage my Discourse instances. Thank you!

rsmithlal commented 2 years ago

@badsyntax I finally figured out what was going wrong with using your plugin on my server. There is an undeclared dependency on python3 andpython3-yaml. All servers using this plugin MUST have those dependencies installed before it will work. I had python3 but not python3-yaml, and the plugin was swallowing the python error and silently failing when running the following line: https://github.com/badsyntax/dokku-discourse/blob/c5ef60411ae5f8929a90dd27613f41f67f0770eb/internal-functions#L63

When I modified the file on my server to try and debug the issue, I encountered the following error when running the evaluated expression on line 63: /var/lib/dokku/plugins/available/discourse/containers/update-env /home/dokku/discourse-test/discourse_standalone.yml '' '' '' '' '' ''

File "/var/lib/dokku/plugins/available/discourse/containers/update-env", line 4, in <module>
    from yaml import load, dump
ModuleNotFoundError: No module named 'yaml'

Is there some way that I can contribute this requirement to the documentation or otherwise improve the script to let the user know when the dependency is not met rather than silently failing?