Developing Discourse on GitHub Codespaces

GitHub Codespaces is a very fast way to get started with Discourse development. Their free tier is good for 30 hours per month of a 4-core machine.

Getting Started

  1. Navigate to the github repository

  2. Press the , (comma) key on your keyboard, to open GitHub codespaces

  3. Use ‘change options’ to customize the machine. Technically, the 2-core machine will work, but we recommend using at least 4-core for a better experience.

  4. Click “Create Codespace”

  5. Wait for the container to download and start. When it’s done, the README will appear, and you’ll see the Discourse filesystem in the sidebar.

  6. Run the default build task using Ctrl + Shift + B (Cmd + Shift + B on mac).

    This will install dependencies, migrate the database, and start the server. It’ll take a few minutes, especially on the lower-end machines. You’ll see “Build successful” in the terminal when it’s done.

  7. Visit the “Ports” tab, and click the :globe_with_meridians: button for port 4200. This will open a new tab showing your development copy of Discourse

  8. All done! You can now make changes in the codespace and see them reflected in the preview.

The VSCode environment will automatically be configured with our recommended settings and extensions, including automatic linting and formatting.

To minimize usage, make sure to run “Codespaces: Stop Current Codespace” from the command palette (Ctrl + Shift + P or Cmd + Shift + P) when you’re finished. If you forget to do this, the Codespace should be shut down automatically after your account’s configured idle time (default 30 mins). But, there are some situations where the codepace will not be detected as idle, so it’s best to stop it deliberately.

Tips

  • You can launch a codespace from specific branches/PRs - just visit it, and press ,

  • You can manage all your codespaces at Sign in to GitHub · GitHub

  • Discourse’s sample vscode .vscode/settings.json and .vscode/tasks.json will be copied when you first boot the codespace. From that point forward, if you want to use the latest sample config, you’ll need to manually copy .vscode/settings.json.sample to .vscode/settings.json.


This document is version controlled - suggest changes on github.

7 Likes

I found a problem: it creates the following categories when started:
General, Staff, Staff67d17c71d8026b365c4c6657a9a9b5eb, and General(followed by random string and numbers).
Can those with the random string an numbers not be made? I could delete the General clone, but not the Staff vlone, as it has the FAQ topic (this is also in the regular Staff cat, so there’s no point).

Edit: Site Feedbackee4d95d3ac0267109c01ed5438943e6c is also made, though there already is a Site feedback . Uncategorized has a clone as well.

1 Like

This reminds me of Random string in category name

1 Like

i press the comma (,) when i open the repository and nothing happened

When backing up the database, I get this error:

[2024-12-12 10:31:26] [STARTED]
[2024-12-12 10:31:26] 'system' has started the backup!
[2024-12-12 10:31:26] Marking backup as running...
[2024-12-12 10:31:26] Making sure '/workspace/discourse/tmp/backups/default/2024-12-12-103126' exists...
[2024-12-12 10:31:26] Making sure '/workspace/discourse/public/backups/default' exists...
[2024-12-12 10:31:26] Updating metadata...
[2024-12-12 10:31:27] Dumping the public schema of the database...
[2024-12-12 10:31:28] pg_dump: error: connection to database "discourse_development" failed: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
[2024-12-12 10:31:28] EXCEPTION: pg_dump failed
[2024-12-12 10:31:28] /workspace/discourse/lib/backup_restore/backuper.rb:173:in `dump_public_schema'
/workspace/discourse/lib/backup_restore/backuper.rb:36:in `run'
/workspace/discourse/lib/backup_restore.rb:13:in `backup!'
/workspace/discourse/app/jobs/regular/create_backup.rb:10:in `execute'
/workspace/discourse/app/jobs/base.rb:322:in `block (2 levels) in perform'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management.rb:21:in `with_connection'
/workspace/discourse/app/jobs/base.rb:309:in `block in perform'
/workspace/discourse/app/jobs/base.rb:305:in `each'
/workspace/discourse/app/jobs/base.rb:305:in `perform'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:202:in `execute_job'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:170:in `block (2 levels) in process'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/middleware/chain.rb:177:in `block in invoke'
/workspace/discourse/lib/sidekiq/pausable.rb:132:in `call'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/middleware/chain.rb:179:in `block in invoke'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/middleware/chain.rb:182:in `invoke'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:169:in `block in process'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:136:in `block (6 levels) in dispatch'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/job_retry.rb:113:in `local'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:135:in `block (5 levels) in dispatch'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq.rb:44:in `block in <module:Sidekiq>'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:131:in `block (4 levels) in dispatch'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:263:in `stats'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:126:in `block (3 levels) in dispatch'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/job_logger.rb:13:in `call'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:125:in `block (2 levels) in dispatch'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/job_retry.rb:80:in `global'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:124:in `block in dispatch'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/job_logger.rb:39:in `prepare'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:123:in `dispatch'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:168:in `process'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:78:in `process_one'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/processor.rb:68:in `run'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/component.rb:8:in `watchdog'
/home/discourse/.bundle/gems/ruby/3.3.0/gems/sidekiq-6.5.12/lib/sidekiq/component.rb:17:in `block in safe_thread'
[2024-12-12 10:31:28] Cleaning stuff up...
[2024-12-12 10:31:28] Removing '.tar' leftovers...
[2024-12-12 10:31:28] Marking backup as finished...
[2024-12-12 10:31:28] Notifying 'system' of the end of the backup...

This happens whenever I boot up the forum with bin/ember-cli-u.

When clicking the Backup in the Admin panel, I get:

[2024-12-12 10:34:57] [STARTED]
[2024-12-12 10:34:57] 'NateDhaliwal' has started the backup!
[2024-12-12 10:34:57] Marking backup as running...
[2024-12-12 10:34:57] Making sure '/workspace/discourse/tmp/backups/default/2024-12-12-103457' exists...
[2024-12-12 10:34:57] Making sure '/workspace/discourse/public/backups/default' exists...
[2024-12-12 10:34:57] Updating metadata...
[2024-12-12 10:34:57] Dumping the public schema of the database...
[2024-12-12 10:34:57] pg_dump: error: connection to database "discourse_development" failed: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
[2024-12-12 10:34:57] EXCEPTION: pg_dump failed
[2024-12-12 10:34:57] /workspace/discourse/lib/backup_restore/backuper.rb:173:in `dump_public_schema'
/workspace/discourse/lib/backup_restore/backuper.rb:36:in `run'
/workspace/discourse/script/spawn_backup_restore.rb:9:in `backup'
/workspace/discourse/script/spawn_backup_restore.rb:31:in `block in <main>'
/workspace/discourse/script/spawn_backup_restore.rb:4:in `fork'
/workspace/discourse/script/spawn_backup_restore.rb:4:in `<main>'
[2024-12-12 10:34:57] Cleaning stuff up...
[2024-12-12 10:34:57] Removing '.tar' leftovers...
[2024-12-12 10:34:57] Marking backup as finished...
[2024-12-12 10:34:57] Notifying 'NateDhaliwal' of the end of the backup...