Beginners Guide to Install Discourse for Development using Docker

Yikes d/cleanup is dangerous. That’s a good way to lose a lot of Docker work unrelated to Discourse at all…

I started doing some manual hacks like the following which were working but there kept being more and more permission issues, so I decided to stop trying to put out fires.

mkdir app/assets/javascripts/plugins
mkdir tmp
sudo chown 1000:1000 tmp
sudo chown 1000:1000 app/assets/javascripts/plugins

I’m going to use the host user with a uid of 1000 and I bet that it’s just going to work now, but this really exposes a shortcoming with how Discourse development is done it seems.

…and yep that did the trick.

In the case of that “tmp” that could be in a named or anonymous Docker volume. With the plugins, it could be useful to have that mounted volume but the host file system permissions would need to be altered to support writes.

I don’t think it’s safe to assume that every developer will be using a uid of 1000.

Hi guys, do you know how to run the development using old version discourse ? I know that in live discourse we can set version in app.yml. But I don’t know how to do it in development using docker. I want to run development on last stable version v2.7.10. Thanks for your help

Just checkout that branchor commit in git. (The way that I do it is to google

You’ll need to drop, create, and migrate the database after you downgrade.

Hi thanks @pfaffman ,

I did fresh git pull of discourse and checkout to “stable” version branch. (which is use discourse v2.7.10 tag)

I run dev init and set the admin user email and password

d/boot_dev --init

and run rails server it will listen on port 3000

d/rails s

then run ember-cli

cd app/assets/javascripts/discourse
yarn run ember serve --proxy "http://localhost:3000"

the discourse development can be open on “http://localhost:4200

however I got issue when login as admin user (the one that I created when run “d/boot_dev --init”)

“Unkown error” pop up showed on screen, with below error on /logs

ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR:  function max(boolean) does not exist
LINE 1: ..._rank, MAX(user_badges.created_at) AS created_at, MAX(user_b...
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
lib/freedom_patches/ams_include_without_root.rb:49:in `include!'
app/controllers/application_controller.rb:495:in `serialize_data'
app/controllers/application_controller.rb:504:in `render_serialized'
app/controllers/session_controller.rb:611:in `login'
app/controllers/session_controller.rb:337:in `create'
app/controllers/application_controller.rb:395:in `block in with_resolved_locale'
app/controllers/application_controller.rb:395:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/missing_avatars.rb:23:in `call'
lib/middleware/turbo_dev.rb:34:in `call'

Do you have some experience with that error ? or maybe my step on running development on previous version was wrong ?

I think you need to rm -r the database. I’m not sure where it is, but it’s likely in the OP.

1 Like

Hi all,

Went fully clean slate again. All goes well, get a pristine development environment that I can log into.

Then I am getting a couple of plugins in to match my production environment and pull the most recent backup.

Upload it, try to restore it to the development environment and I get the Peer authentication error again. Have filed a bug, but so far there is no response. Can anyone try to reproduce? I’ve seen similar issues further op the comments to this post, so I figure I am not alone on this one?

[2021-11-29 19:43:39] 'koen' has started the restore!
[2021-11-29 19:43:39] Marking restore as running...
[2021-11-29 19:43:39] Making sure /src/tmp/restores/default/2021-11-29-194339 exists...
[2021-11-29 19:43:39] Copying archive to tmp directory...
[2021-11-29 19:43:39] Extracting dump file...
[2021-11-29 19:43:40] Validating metadata...
[2021-11-29 19:43:40]   Current version: 20211124161346
[2021-11-29 19:43:40]   Restored version: 20211123033311
[2021-11-29 19:43:40] Enabling readonly mode...
[2021-11-29 19:43:40] Pausing sidekiq...
[2021-11-29 19:43:40] Waiting up to 60 seconds for Sidekiq to finish running jobs...
[2021-11-29 19:43:46] Creating missing functions in the discourse_functions schema...
[2021-11-29 19:43:46] Restoring dump file... (this may take a while)
[2021-11-29 19:43:47] psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
[2021-11-29 19:43:47] EXCEPTION: psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"

[2021-11-29 19:43:47] /src/lib/backup_restore/database_restorer.rb:92:in `restore_dump'
/src/lib/backup_restore/database_restorer.rb:26:in `restore'
/src/lib/backup_restore/restorer.rb:51:in `run'
/src/script/spawn_backup_restore.rb:23:in `restore'
/src/script/spawn_backup_restore.rb:36:in `block in <main>'
/src/script/spawn_backup_restore.rb:4:in `fork'
/src/script/spawn_backup_restore.rb:4:in `<main>'
[2021-11-29 19:43:47] Trying to rollback...
[2021-11-29 19:43:47] There was no need to rollback
[2021-11-29 19:43:47] Cleaning stuff up...
[2021-11-29 19:43:47] Dropping functions from the discourse_functions schema...
[2021-11-29 19:43:47] Removing tmp '/src/tmp/restores/default/2021-11-29-194339' directory...
[2021-11-29 19:43:47] Unpausing sidekiq...
[2021-11-29 19:43:47] Marking restore as finished...
[2021-11-29 19:43:47] Notifying 'koen' of the end of the restore...
[2021-11-29 19:43:51] Finished!