تثبيت Discourse للتطوير باستخدام Docker

التطوير باستخدام دوكر (Docker)

بما أن ديسكورس (Discourse) يعمل في دوكر، يجب أن تكون قادرًا على تشغيل ديسكورس مباشرةً من دليل المصدر الخاص بك باستخدام حاوية تطوير ديسكورس.

:white_check_mark: الإيجابيات: لا حاجة لتثبيت أي تبعيات نظام، ولا حاجة لأي إعدادات على الإطلاق لإعداد بيئة تطوير سريعة.

:x: السلبيات: ستكون أبطأ قليلاً من بيئة التطوير الأصلية على أوبونتو (Ubuntu)، وأبطأ بكثير من التثبيت الأصلي على ماك أو إس (MacOS).

راجع أيضًا Developing Discourse using a Dev Container

الخطوة 1: تثبيت دوكر (Docker)

أوبونتو (Ubuntu)

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce

19.10

sudo apt-get install docker.io
sudo usermod -a -G docker $USER
sudo reboot

ويندوز نظام فرعي لينكس (Windows WSL): أوبونتو (Ubuntu)

يمكنك تشغيل الأوامر المذكورة أعلاه داخل نظام WSL ولكن يجب أن تكون جميع الملفات داخل نظام ملفات WSL. على سبيل المثال، يعمل بشكل جيد إذا كانت داخل ~/discourse ولكنه يفشل إذا تم وضعها داخل /mnt/c/discourse.

ماك أو إس (MacOS)

:warning: صورة دوكر لتطوير ديسكورس متاحة فقط لمعماريات x86_64. يمكن لأجهزة ماك M1 بدء تشغيل الصورة باستخدام محاكاة المعماريات، ولكن من غير المرجح أن يتم تشغيل ديسكورس بسبب نقص دعم inotify في QEMU.

بدلاً من ذلك، يجب عليك استخدام Install Discourse on macOS for development

الخيار 1: قم بتنزيل حزمة .dmg من متجر دوكر (Docker store)
الخيار 2: brew install docker

الخطوة 2: تشغيل الحاوية

انسخ مستودع ديسكورس إلى جهازك المحلي.

git clone https://github.com/discourse/discourse.git
cd discourse

(من جذر المصدر الخاص بك)

d/boot_dev --init
    # انتظر أثناء:
    #   - تثبيت التبعيات،
    #   - ترحيل قاعدة البيانات، و
    #   - إنشاء مستخدم إداري (ستحتاج إلى التفاعل مع هذا)

# في طرفية واحدة:
d/rails s

# وفي طرفية منفصلة
d/ember-cli

… ثم افتح متصفحًا على http://localhost:4200 و ها أنت ذا!، يجب أن ترى ديسكورس.

روابط رمزية للإضافات (Plugin Symlinks)

يتيح تدفق تطوير دوكر الروابط الرمزية تحت الدليل plugins/، مع التحذير التالي:

كلما تم إنشاء رابط رمزي جديد للإضافة، يجب إعادة تشغيل حاوية دوكر باستخدام:

d/shutdown_dev; d/boot_dev

ملاحظات:

  • لاختبار رسائل البريد الإلكتروني، قم بتشغيل MailHog:

    d/mailhog
    
  • إذا كانت هناك أحجار كريمة (gems) مفقودة، قم بتشغيل:

    d/bundle install
    
  • إذا كانت هناك حاجة لترحيل قاعدة بيانات (db migration):

    d/rake db:migrate RAILS_ENV=development
    
  • عند الانتهاء، يمكنك اختيار إيقاف حاوية دوكر باستخدام:

    d/shutdown_dev
    
  • تتم استدامة البيانات بين استدعاءات الحاوية في دليل tmp/postgres الخاص بجذر المصدر الخاص بك. إذا كنت تريد لأي سبب إعادة تعيين قاعدة البيانات الخاصة بك قم بتشغيل:

    sudo rm -fr data
    
  • إذا رأيت أخطاء مثل “permission denied while trying to connect to Docker” (تم رفض الإذن أثناء محاولة الاتصال بـ Docker)، قم بتشغيل:

    run `sudo usermod -aG docker ${USER}`
    sudo service docker restart
    
  • إذا كنت ترغب في الكشف عن المنافذ من الحاوية للشبكة عالميًا (إيقاف التشغيل افتراضيًا) استخدم:

    d/boot_dev -p
    
  • يأتي ملف Dockerfile من discourse/discourse_docker على GitHub، وتحديداً image/discourse_dev.

تشغيل الاختبارات

d/rake autospec

لتشغيل اختبارات إضافات معينة، يمكنك أيضًا القيام بشيء مثل هذا:

d/rake plugin:spec["discourse-follow"]

أو حتى شيء كهذا ليكون أكثر تحديدًا:

my-machine:~/discourse$ d/shell
discourse@discourse:/src$ RAILS_ENV=test /src/bin/rspec plugins/discourse-follow/spec/lib/updater_spec.rb:37

يتم التحكم في إصدار هذه الوثيقة - اقترح التغييرات على GitHub.

72 إعجابًا
Using a launcher built docker image in docker-compose
IDE and comfortable DEV environment for newbies
Docker install on MacOS
Installing Discourse for macOS Development Using asdf and docker-compose
How to install Discourse locally?
Discourse developement environment setup
Discourse on local pc
External database ENV VARs not documented (external PG Port, external Redis ENV VARs)
How to Install Discourse on LocalHost in Windows?
Unicode (Russian) username validation fails randomly
Qunit in Docker
Is it possible to use a local plugin directory with a docker install?
Is it possible to use a local plugin directory with a docker install?
Problem with development on Windows with Docker and mounted volume
[Resolved] Recent change breaks connectivity in Docker (+ non-Docker)
How might we better structure #howto?
Apple M1 for discourse development
How to open via internal IP?
Fast, efficient plugin development with Docker dev install (Windows WSL2)
How do I install a stable version of Discourse on Docker locally?
Backup fails on localhost with docker
How do I install a stable version of Discourse on Docker locally?
Problems with understanding the development of Discourse
Need to create custom static page as home page
Docker new licensing
Install Discourse Docker on Ubuntu 11
Backup restore failing on clean dev docker env: FATAL: Peer authentication failed for user “postgres”
Install Discourse on macOS for development
Can't build Discourse on Ubuntu 20.10
Installing discourse for development is failing
Create, download, and restore a backup of your Discourse database
Set up a local Discourse Development Environment?
How do you install Discourse using Windows 10 Docker Desktop?
NoMethodError: undefined method `min_tags_from_required_group'
Install plugins in your non-Docker development environment
NoMethodError: undefined method `min_tags_from_required_group'
Error installing `bullseye-backports` when trying to install for Development
What I should do for migration from Cusdis to Discourse
Migrate a MyBB forum to Discourse
Local installation internal use only
Maintaining an up-to-date development environment
PG::UndefinedTable: ERROR: relation "pg_range" does not exist
Docker-compose.yml to run discourse locally
Allow subscription of predetermined length
Cannot load any images “Uncaught (in promise) no-response: no-response”
Discovery document is missing
What are the benefits of a dev environment?
Installing Discourse on windows using Docker Desktop
'Arrive at topic' info missing from email when re-sending invites
External database ENV VARs not documented (external PG Port, external Redis ENV VARs)
How to troubleshoot database errors in an outdated plugin?
Error when building: discourse does not support compiling scss/sass files via sprockets
Integration into custom auth system where emails are not unique?
Installer un environnement developpement discourse sur windows
Contributing to Discourse development
Install Discourse on Ubuntu or Debian for Development
There was an error while trying to write to `/src/Gemfile.lock`. It is likely that you need to grant write permissions for that path
Tags rearranged, triggering an extra edit
Ember addons are resolving as incorrect peer dependencies. -- fixed by removing "content-tag@3.1.0": "patches/content-tag@3.1.0.patch",
Trying to install Discourse on portainer but it's not pulling the base container
Developing Discourse using a Dev Container
Subscribe to post an ad
Postgres doesn't seem to be running when running Discourse locally using Docker
Discourse OpenID Connect (OIDC)
How can I install Discourse on Windows? Getting restarting (100) error
Dev environment: recommended way to bootstrap the first admin account without email?
Dev environment: recommended way to bootstrap the first admin account without email?
Total newbie struggling to preview the signup modal with my test theme, what am I missing?
Configure Discourse to use a separate PostgreSQL server
Installing discourse follow plugin in development (boot_dev) setup — no app.yml file
Discourse API developers docker-compose basic image
Which is the better option to self-host?
Using a launcher built docker image in docker-compose
Without any coding knowledge, is it possible to install and maintain Discourse?
I want to install a plugin for development, what should I do?
Can't uninstall on Ubuntu 18.04
Developing Discourse using a Dev Container
Using a launcher built docker image in docker-compose
Bundle install fails after adding gem "mysql2" and gem "reverse_markdown"
Issue in setup discourse on ubuntu server
`script/osx_dev` script is pretty broken
Can't set up dev environment due to cppjieba_rb failing to install
I want to install a plugin for development, what should I do?
Stuck in infinite loop in Mac terminal after source ~/.bashrc
Install on macOS – Failure: Scheduler::Defer can pause and resume
Install on macOS – Failure: Scheduler::Defer can pause and resume
Install Discourse for Development using Docker is Failed
OAuth2 and Microsoft ADFS
Migrate a phpBB3 forum to Discourse
Availability of OpenID Connect in hosted plans
Can't set up dev environment due to cppjieba_rb failing to install
Adding command line tools support for user api keys
Adding command line tools support for user api keys
Discourse redirects to the OAuth server after loading `/?authComplete=true`
Hello from Gitpod! (installing on google cloud + automated dev setup)