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 Cmd/Ctrl + Shift + B.

    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. Run the dev/admin/create task. Open the command palette with Cmd/Ctrl + Shift + P and search for “Tasks: Run Tasks”. It will present a menu of tasks; select dev/admin/create off of that list. You’ll be prompted to enter an email address and a password for your admin user.

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

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

Running tests

The first time you run tests, you’ll need to install testing dependencies, including Playwright and the discourse_test DB. You can run the deps/testing task to install those. Open the command palette, select “Tasks: Run Tasks”. It will present a menu of tasks; select deps/testing off of that list.

Once the test dependencies are installed, you can run bin/lint, bin/qunit, or the system specs

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.

13개의 좋아요

문제를 하나 발견했습니다: 시작할 때 다음 카테고리가 생성됩니다:
General, Staff, Staff67d17c71d8026b365c4c6657a9a9b5eb, 그리고 General(그 뒤에 랜덤 문자열과 숫자가 붙음).
랜덤 문자열과 숫자가 붙은 카테고리를 만들지 않을 수 있을까요? General의 복제본은 삭제할 수 있지만, Staff의 복제본은 FAQ 토픽이 포함되어 있어 삭제할 수 없습니다(이 토픽은 원래의 Staff 카테고리에도 이미 있으므로 의미가 없습니다).

수정: Site Feedbackee4d95d3ac0267109c01ed5438943e6c도 생성되는데, 이미 Contribute > 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를 실행하여 포럼을 시작할 때마다 이 문제가 발생합니다.

관리자 패널에서 백업을 클릭하면 다음과 같은 메시지가 표시됩니다:

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

이미지에 나와 있듯이 main에서 devcontainer로 변경하려고 하면 아무것도 나오지 않고 '결과 없음’이라고 표시됩니다.

두 번째 이미지의 푸터에 표시된 ‘devcontainer’ 브랜치를 말씀하시는 거라면, 무시하시면 됩니다. 스크린샷은 main 브랜치에서 devcontainer 구성이 사용 가능해지기 전에 촬영된 것이기 때문입니다.

대비, 고마워

하지만 그 버튼을 누르기 전에 코드에서 관리자 계정을 만들어야 합니다. 제발 어떻게 하는지 보여줄 수 있는 이미지를 보내줄 수 있나요? 마침 제 own discourse를 가질 수 있게 되었지만, 설정하는 방법을 모르면 할 수가 없거든요. 그래서 어떻게 해야 하는지 볼 수 있도록 이미지를 보내줄 수 있나요?

Docker를 사용하지 않는 다른 설치 방법에서 설명된 단계를 사용할 수 있습니다. 예: Install Discourse on Ubuntu or Debian for Development

관리자 계정을 생성하는 명령어는 bin/rails admin:create이며, 이후 프롬프트에 따라 진행하면 됩니다.

3개의 좋아요

동작하네요! 정말 감사합니다. 이제 제 포럼을 갖게 되었어요.

@david 이 문제에 대해 아이디어가 있나요? 여전히 이 오류가 발생합니다.

이 시스템은 디스커스 플러그인과 호환되나요? 가능한가요?

네, 시도해 보았고 플러그인이 이 환경에서 정상적으로 작동합니다.
설치 방법은 다음과 같습니다:

현재 게시글 투표, 주제 투표, 게이미피케이션 플러그인을 설치했으며, 지금까지 잘 작동하고 있습니다.

3개의 좋아요

네, 그냥 클라우드에서 표준 도커 컨테이너를 실행하는 것이라서 cd 명령으로 플러그인 디렉터리로 이동한 후 원하는 것을 클론하면 됩니다.

언젠가는 개별 플러그인 저장소에 설정 파일을 포함할 수 있으면 좋겠습니다. 그러면 코드시페이스 환경을 해당 저장소에서 바로 시작할 수 있을 테니까요.

6개의 좋아요

이 문제가 Codespaces와 관련이 있는지, 아니면 단순히 Linux 환경 문제인지 확실하지 않습니다. 하지만 사용자 impersonation(대리)을 수행하면서 사용자를 전환하고 로그인/로그아웃을 하면 bin/ember-cli -u가 아무런 오류 로그 없이 종료됩니다. Codespace는 Discourse 저장소와 최신 상태가 유지되고 있습니다.

2번째 개발 환경(이것도 GH Codespaces)에서 매번 로그아웃하지 않아도 되도록 experimental_impersonation을 활성화해야 했습니다.