Beginners Guide to Install Discourse for Development using Docker

bundle install
rake db:migrate

Should do it

2 Likes

I’m not able to get this working. I pulled the latest from the master branch, and then here’s what I did:

  1. d/boot_dev (works)
  2. d/bundle install (works)
  3. d/rails db:migrate RAILS_ENV=development as indicated in the OP, or d/rake db:migrate as you recommended (neither of them work)

Here’s the error I get for one of them (the other is basically the same):

rails aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/src/lib/site_settings/db_provider.rb:61:in `table_exists?'
/src/lib/site_settings/db_provider.rb:16:in `all'
/src/lib/site_settings/defaults_provider.rb:29:in `db_all'
/src/lib/site_setting_extension.rb:290:in `block in refresh!'
/src/lib/site_setting_extension.rb:287:in `synchronize'
/src/lib/site_setting_extension.rb:287:in `refresh!'
/src/lib/site_setting_extension.rb:522:in `block in setup_methods'
/src/config/initializers/004-message_bus.rb:120:in `<main>'
/src/config/environment.rb:7:in `<main>'
bin/rails:17:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment

And here’s the full trace if I add --trace as the error message recommends:

Full trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
rails aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/usr/local/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'
/usr/local/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `new'
/usr/local/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/postgresql_adapter.rb:46:in `postgresql_connection'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_handling.rb:221:in `retrieve_connection'
/usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_handling.rb:189:in `connection'
/src/lib/site_settings/db_provider.rb:61:in `table_exists?'
/src/lib/site_settings/db_provider.rb:16:in `all'
/src/lib/site_settings/defaults_provider.rb:29:in `db_all'
/src/lib/site_setting_extension.rb:290:in `block in refresh!'
/src/lib/site_setting_extension.rb:287:in `synchronize'
/src/lib/site_setting_extension.rb:287:in `refresh!'
/src/lib/site_setting_extension.rb:522:in `block in setup_methods'
/src/config/initializers/004-message_bus.rb:120:in `<main>'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:318:in `block in load'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:291:in `load_dependency'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:318:in `load'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:666:in `block in load_config_initializer'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/notifications.rb:182:in `instrument'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:665:in `load_config_initializer'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:624:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:624:in `block in <class:Engine>'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
/usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/usr/local/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
/usr/local/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:50:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:50:in `tsort_each_child'
/usr/local/lib/ruby/2.7.0/tsort.rb:415:in `call'
/usr/local/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
/usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
/usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
/usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
/usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
/usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
/usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:363:in `initialize!'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/railtie.rb:190:in `public_send'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/railtie.rb:190:in `method_missing'
/src/config/environment.rb:7:in `<main>'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/usr/local/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `block in require'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:291:in `load_dependency'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `require'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:339:in `require_environment!'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `invoke_prerequisites'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `invoke_prerequisites'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/command.rb:48:in `invoke'
/usr/local/lib/ruby/gems/2.7.0/gems/railties-6.0.3.3/lib/rails/commands.rb:18:in `<main>'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/usr/local/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `block in require'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:291:in `load_dependency'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `require'
bin/rails:17:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment

Besides it sounding like it can’t connect to the database, I have no idea what any of this means. I don’t even know how to tell if a database migration is even necessary, other than me assuming it is from chatter on the forums over the last year.

Once this failed I figured I’d try just running d/unicorn in case the database migration wasn’t relevant, but that also failed with the following error at the end:

7: from /usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection'
	 6: from /usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
	 5: from /usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection'
	 4: from /usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection'
	 3: from /usr/local/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/postgresql_adapter.rb:46:in `postgresql_connection'
	 2: from /usr/local/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
	 1: from /usr/local/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `new'
/usr/local/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg.rb:58:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

So it seems to be the same issue effectively. Any suggestions for how to fix this connection issue or anything else that you may notice being wrong based on the traces?

1 Like

See my post above.

It might be related.

My sense was that my problem was related to a migration to Postgres 13 that is automated on full installs but doesn’t get run on development. (an assumption).

See my followup post.

In the end I went nuclear, recreated the data and restored.

1 Like

Yeah, I don’t really have any data worth keeping anyway. So clearing all the data is probably the simplest approach if that’ll work. Was just running sudo rm -fr data and d/boot_dev --init again sufficient to gets things back up and running? I’m not sure what you mean by “restored” though if you could clarify that part.

1 Like

Yeah, I did have data I needed so cleared the data down and did a RESTORE from backup.

2 Likes

I did get my environment working again by deleting data and reinitializing, so now I can use the app including the plugin I was testing. However, I’m getting an error when I run tests against my plugin and another plugin that I tried to make sure it wasn’t just mine. I posted a separate topic about it, but I’m not sure if it’s related to my docker setup, so I wanted to cross-post here.

2 Likes

I am using Ubuntu WSL 2 in windows.

When I run:
d/boot_dev --init

nothing happens. It just starts a new line, with no execution signs. Any idea what’s going on here? Docker and git installed though.

Thank you.

1 Like
  1. You installed Docker within WSL 2 and not on Windows itself, right?
  2. What directory are you running the command from? It should be from the top-level directory in the discourse repo.
2 Likes

Yes, I did install docker in both windows as well as inside Ubuntu WSL 2.
And I did run the command from /discourse directory.
But nothing shows up when I press return.

Not even any error logs or anything. So, it’s quite frustrating to know where to start from.

1 Like

Hi all, question: if I use Digital Ocean’s one-click install (https://marketplace.digitalocean.com/apps/discourse) is this considered a developing environment? I’m sorry in advance for my ignorance, but I’m having trouble understanding what separates production from developing environments, and I’d like to start the long slow journey on learning plugin development.

A few things: (1) I have and old mac (2012) with an old OS (10.12.6), and I can’t manually install via terminal all that is needed for a local installation of discourse – I have to build much from source, and eventually I run into a “make” that never ends, and (2) I have successfully created discourse forums on one-click DO droplets in the past, but only for production – not development.

Any and all help/guidance/advice would be much appreciated!

1 Like

Hello!

I have managed to install Discourse on Windows using WSL.

Prerequisites that i have done.

  • Enable WSL with version 2
  • I am using Ubuntu 20.04
  • Set up your distribution :slight_smile: Follow the given instructions and you are ready to go

In the distribution, under my home home folder, /home/cosmin.

  • Install Docker as instructed in the first post. The installation part of docker.io was not necessary for me. I only executed sudo usermod -a -G docker $USER
  • After the Docker installation is complete, start the service with sudo docker service start and check it
  • cd discourse
  • Run d/boot_dev --init and wait to finish
  • Run in discourse folder, run d/unicorn and you are ready yo go

Note:
If the commands are reporting permissions error, try with sudo

Hope this helps :slight_smile:
Have a nice day or evening!
Cosmin

4 Likes

Thanks for sharing your setup; however, I don’t have Windows. I’m specifically curious about the one-click Digital Ocean setup – is it suitable for development?

1 Like

Hello,

I’m getting this error when trying to run d/boot_dev --init

Errno::EACCES: Permission denied @ dir_s_mkdir - tmp
/src/config/boot.rb:23:in `<top (required)>'
/src/config/application.rb:16:in `require'
/src/config/application.rb:16:in `<top (required)>'
/src/Rakefile:7:in `require'
/src/Rakefile:7:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)

Any ideas on how I fix it? Tried searching for it everywhere but didn’t find any solutions.

Edit: fixed it by doing chmod -R 777 ~/discourse, but now I’m getting this error:

gifsicle worker: gifsicle not found; please provide proper binary or disable this worker (--no-gifsicle argument or :gifsicle => false through options)

2 Likes

That is not an issue, we removed our usage recently, the warning is not a concern. Are you working against old Discourse code?

4 Likes

Nope, it was the recent release. But I followed this DigitalOcean’s tutorial and it’s perfectly working now.

2 Likes

How to use plugins in this kind of setup?
I am trying to follow Install Plugins in Discourse, but it mentions /var/discourse/containers/app.yml file, which does not exist in my discourse directory.

I’ve got building a discourse dev environment working and able to test my patch, but how do I get my patch into my production instance? I tried building base, and then ./launcher rebuild app --run-image discourse/base:build, but it doesn’t seem to result in a running Discourse instance.

Usually I get an error about the syslog group missing, but I commented that out, and still didn’t end up with a running site. And nothing of note in docker logs.

We don’t really document this kind of stuff, but you would generate a “diff” file, the git apply the diff in a hook after you clone the repo. app.yml supports hooks.

A quick-and-dirty solution for self hosted single container things is just to edit the code in place and run sv restart unicorn

2 Likes

Not sure if this is the best place to ask about this problem but I’ve been unable to finish the Discourse installation using Docker on an Apple M1 computer.

After I run d/boot_dev --init all dependencies are installed without any apparent problem but once I get to the Migrating database step, it stays there consuming 100% of one of my cores and it doesn’t seem to move from there.

I tried logging in to the docker container and the bundle migrate task is running at 100% but no apparent activity on the posgresql process.

Any ideas would be very helpful!

1 Like

I think the virtualization support is really really new, not surprised it is a bit of an adventure.

@pmusaraj / @david any luck getting docker-dev working on m1?

5 Likes