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 إعجابًا

لقد وجدت مشكلة: يقوم بإنشاء الفئات التالية عند البدء:
عام، موظفون، موظفون67d17c71d8026b365c4c6657a9a9b5eb، وعام (متبوع بسلسلة عشوائية وأرقام).
هل يمكن عدم إنشاء تلك التي تحتوي على سلسلة عشوائية وأرقام؟ يمكنني حذف النسخة المكررة من “عام”، ولكن ليس النسخة المكررة من “موظفون”، لأنها تحتوي على موضوع الأسئلة الشائعة (هذا موجود أيضًا في فئة “موظفون” العادية، لذلك لا فائدة منه).

تعديل: تم أيضًا إنشاء 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 كما هو موضح في الصورة، لا أحصل على أي شيء، ويقول لا توجد نتائج.

إذا كنت تتحدث عن فرع ‘devcontainer’ الموضح في تذييل الصورة الثانية، فيجب عليك تجاهله. تم التقاط لقطات الشاشة قبل توفر تكوين devcontainer على الفرع main.

شكرا ديفيد

قبل الضغط عليه، تحتاج إلى إنشاء حساب مسؤول في الكود. هل يمكن لأحد أن يرسل لي بعض الصور توضح كيفية القيام بذلك لأنني أخيرًا لدي طريقة للوصول إلى Discourse الخاص بي ولكن لا يمكنني القيام بذلك دون معرفة كيفية إعداده، لذا هل يمكن لأحد أن يقدم صورًا حتى أتمكن من رؤية كيفية القيام بذلك؟

يمكنك استخدام الخطوات الموضحة في عمليات التثبيت الأخرى غير المعتمدة على Docker، مثل Install Discourse on Ubuntu or Debian for Development

الأمر لإنشاء حساب مسؤول هو bin/rails admin:create ثم تتبع المطالبات

3 إعجابات

لقد نجح الأمر شكراً جزيلاً، لدي الآن منتدى خاص بي

@david أي أفكار لهذا؟ ما زلت أواجه هذا الخطأ.

هل يعمل هذا النظام مع إضافات Discourse؟ هل يمكنه ذلك؟

نعم، لقد حاولت وتعمل الإضافات مع هذا.
يمكن تثبيتها عن طريق:

لقد قمت بتثبيت التصويت على المشاركات، والتصويت على المواضيع، والألعاب، وهي تعمل حتى الآن.

3 إعجابات

نعم، الأمر فقط تشغيل حاوية دوكر القياسية لدينا في السحابة، لذا يمكنك أن تغير إلى مجلد الإضافات ونسخ أي شيء تريده.

في يوم من الأيام، قد يكون من الجميل إذا استطعنا أن نضع تكوينًا في مستودعات الإضافات الفردية، بحيث يمكن إطلاق بيئة الـ codespaces مباشرة من مستودعاتها.

6 إعجابات

لست متأكدًا مما إذا كان هذا متعلقًا بـ Codespaces أم ببيئة Linux فقط، ولكن عندما أسجل الدخول والخروج أثناء انتحال شخصية والتبديل بين المستخدمين، فإن bin/ember-cli -u يتوقف ببساطة، دون أي سجلات تشير إلى أي أخطاء قد تكون سببت ذلك. و Codespace محدث بمستودع Discourse.