Cannot rebake after setting up CDN

I’m trying to setup S3 CDN, but when entering the app and rebaking, I get a large block of output following rake aborted!

I am running discourse from the Digital Ocean Marketplace App (docker). Here is what outputs:

ActiveRecord::NoDatabaseError: FATAL:  Peer authentication failed for user "discourse"
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:50:in `rescue in postgresql_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:33:in `postgresql_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_handling.rb:221:in `retrieve_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_handling.rb:189:in `connection'
/var/www/discourse/lib/site_settings/db_provider.rb:61:in `table_exists?'
/var/www/discourse/lib/site_settings/db_provider.rb:16:in `all'
/var/www/discourse/lib/site_settings/defaults_provider.rb:29:in `db_all'
/var/www/discourse/lib/site_setting_extension.rb:290:in `block in refresh!'
/var/www/discourse/lib/site_setting_extension.rb:287:in `synchronize'
/var/www/discourse/lib/site_setting_extension.rb:287:in `refresh!'
/var/www/discourse/lib/site_setting_extension.rb:522:in `block in setup_methods'
/var/www/discourse/config/initializers/004-message_bus.rb:120:in `<main>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:318:in `block in load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:318:in `load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:666:in `block in load_config_initializer'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/notifications.rb:182:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:665:in `load_config_initializer'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:624:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:624:in `block in <class:Engine>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:32:in `instance_exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:32:in `run'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:61:in `block in run_initializers'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:50:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:50:in `tsort_each_child'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:60:in `run_initializers'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/application.rb:363:in `initialize!'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/railtie.rb:190:in `public_send'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/railtie.rb:190:in `method_missing'
/var/www/discourse/config/environment.rb:7:in `<main>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/application.rb:339:in `require_environment!'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'

Caused by:
PG::ConnectionBad: FATAL:  Peer authentication failed for user "discourse"
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `new'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:46:in `postgresql_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_handling.rb:221:in `retrieve_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.5/lib/active_record/connection_handling.rb:189:in `connection'
/var/www/discourse/lib/site_settings/db_provider.rb:61:in `table_exists?'
/var/www/discourse/lib/site_settings/db_provider.rb:16:in `all'
/var/www/discourse/lib/site_settings/defaults_provider.rb:29:in `db_all'
/var/www/discourse/lib/site_setting_extension.rb:290:in `block in refresh!'
/var/www/discourse/lib/site_setting_extension.rb:287:in `synchronize'
/var/www/discourse/lib/site_setting_extension.rb:287:in `refresh!'
/var/www/discourse/lib/site_setting_extension.rb:522:in `block in setup_methods'
/var/www/discourse/config/initializers/004-message_bus.rb:120:in `<main>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:318:in `block in load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:318:in `load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:666:in `block in load_config_initializer'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/notifications.rb:182:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:665:in `load_config_initializer'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:624:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/engine.rb:624:in `block in <class:Engine>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:32:in `instance_exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:32:in `run'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:61:in `block in run_initializers'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:50:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:50:in `tsort_each_child'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/initializable.rb:60:in `run_initializers'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/application.rb:363:in `initialize!'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/railtie.rb:190:in `public_send'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/railtie.rb:190:in `method_missing'
/var/www/discourse/config/environment.rb:7:in `<main>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `require'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/application.rb:339:in `require_environment!'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => posts:rebake => environment
(See full trace by running task with --trace)

I ended up installing a new instance of the Digital Ocean provided docker environment to test and it still throws the same error. I would have to assume it’s something within the Digital Ocean droplet setup. Could someone help me figure this out?

We recommend installing following our Discourse official Standard Installation.

Third party packages that are not maintained by us may break at any point, and as we don’t have any idea of how they are made we can’t offer any support for those.

1 Like

I’m pretty sure Digital Ocean’s distribution pulls directly from the current source. They don’t customize anything afaik. They are even referenced in the GitHub official setup. Can you help me troubleshoot this issue?

If you read that page further you will see that what we recommend is using Digital Ocean VPS running

the current supported LTS release of Ubuntu Server

and not their

That said, if you want to debug further are you running it like this?

root@falcoland:~# cd /var/discourse
root@falcoland:/var/discourse# ./launcher enter app
root@falcoland-app:/var/www/discourse# rake posts:rebake
Rebaking post markdown for 'default'
       31 / 31 (100.0%)
31 posts done!
--------------------------------------------------

?

2 Likes

The marketplace app is just a shortcut for spinning up a new droplet VPS with the discourse docker setup script running on login. It is running Ubuntu 20.04. It’s no different than a supported install afaik, just faster if you don’t already have a droplet setup.

And, yes the commands and directories are the same. But it produces the error I posted above.

You can try sharing the app.yml.

My best guess is that the postgres template is missing?

1 Like

Here is the app.yml file. I have hidden my hostnames and email addresses.

## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80"   # http
  - "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "256MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 4

  ## TODO: The domain name this Discourse instance will respond to
  ## Required. Discourse will not work with a bare IP number.
  DISCOURSE_HOSTNAME: redacted

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'redacted'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: redacted
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: redacted
  DISCOURSE_SMTP_PASSWORD: redacted
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: redacted
  DISCOURSE_NOTIFICATION_EMAIL: redacted

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: me@example.com

  ## The http or https CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com

  ## The maxmind geolocation IP address key for IP address lookup
  ## see https://meta.discourse.org/t/-/137387/23 for details
  #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"

Uncomment that line and set the CDN url.

1 Like

I am using the s3 CDN url set via the GUI. I found that enabling the CDN via app.yml setting would prevent the forum form loading.

I can’t imagine why setting the CDN in the ux could cause the error you show in the OP.

I can’t imagine why setting the CDN in the yml file wouldn’t work.

My best guess is that you have something wrong with the CDN and something wrong with your configuration. But I don’t know.

This appears to be the same behavior I experienced after enabling the CDN in the yml:

I’m not sure I understand the described fix though.

Regarding the rebake failure, there really isn’t much I’ve configured beyond the CDN and S3 for uploads and backups. I’ve tried starting from scratch and I experience the same rebake failure after enabling the CDN.

I think you should set up CDN in app.yml just like @pfaffman said.
I think if you set up in the app.yml that will be global. So that would work after rebake.
Which CDN you use?

I use amazon cloudfront. I will give it a shot after work, thank you.

And make sure to see Using Object Storage for Uploads (S3 & Clones) and the after_assets_precompile stanza.

3 Likes

I think he just want to serve files via CDN and not use object storage. But maybe i am wrong.

2 Likes

@pfaffman is correct, I am using s3 object storage as well. I will check my config tonight and make sure I didn’t miss any steps with that. Thanks!

2 Likes

So I did miss adding the after_assets_precompile section entirely. Once I added it and ran rebuild I am able to rebake posts. I am facing another issue now, but I’ve posted in another thread for that. Thank you to all who helped!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.