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 codespace 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.

「いいね!」 12

問題が見つかりました。起動時に次のカテゴリが作成されます。
General、Staff、Staff67d17c71d8026b365c4c6657a9a9b5eb、およびGeneral(ランダムな文字列と数字が続く)。
ランダムな文字列と数字が付いたものは作成されないようにできますか? Generalのクローンは削除できますが、StaffのクローンはFAQトピックが含まれているため削除できません(これは通常のStaffカテゴリにも含まれているため、意味がありません)。

編集:Site Feedbackee4d95d3ac0267109c01ed5438943e6cも作成されますが、すでに#site-feedback が存在します。Uncategorized にもクローンがあります。

「いいね!」 1

これは Random string in category name を思い出させます

「いいね!」 2

データベースをバックアップしようとすると、このエラーが発生します。

[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...

これは、フォーラムを bin/ember-cli-u で起動するたびに発生します。

管理パネルの Backup をクリックすると、次のようなメッセージが表示されます。

[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...

メインから devcontainer に変更しようとすると、画像のように何も表示されず、「結果がありません」と表示されます。

2番目の画像のフッターに示されている「devcontainer」ブランチについて話している場合、それは無視してください。スクリーンショットは、mainブランチでdevcontainer構成が利用可能になる前に撮影されたものです。

デビッドさん、ありがとう

しかし、それを押す前に、コードで管理者アカウントを作成する必要があります。誰か、それをどのように行うかを示す画像をいくつか送ってもらえませんか?ついに自分の Discourse を利用できるようになりましたが、セットアップ方法がわからないと実行できません。どうすればよいか分かるように、誰か画像を提供してもらえませんか?

Docker ベース以外のインストールで説明されている手順、たとえば Install Discourse on Ubuntu or Debian for Development を使用できます。

管理アカウントを作成するためのコマンドは bin/rails admin:create で、その後プロンプトに従います。

「いいね!」 3

うまくいきました、本当にありがとうございます。これで自分のフォーラムができました。

@david これについて何かアイデアはありますか?まだこのエラーが出ています。

このシステムはディスコースプラグインと連携していますか?可能ですか?

はい、試しましたが、プラグインはこれでも機能します。
以下からインストールできます。

投稿投票、トピック投票、ゲーミフィケーションをインストールしましたが、これまでのところ正常に動作しています。

「いいね!」 3

はい、ただクラウドで標準のDockerコンテナを実行しているだけですので、cdコマンドでプラグインのディレクトリに移動し、好きなものをクローンできます。

いつかは、各プラグインリポジトリに設定ファイルを持たせて、コードスペースの環境を直接そのリポジトリから起動できるようになると良いですね。

「いいね!」 6

Codespaces に関連しているのか、それとも単に Linux 環境の問題なのかは分かりませんが、なりすましやユーザー間の切り替えでログイン・ログアウトを繰り返すと、bin/ember-cli -u がエラーの原因を示すログなしで終了します。Codespace は Discourse リポジトリで最新の状態になっています。