Installa Discourse per lo sviluppo usando Docker

Sviluppo con Docker

Dato che Discourse viene eseguito in Docker, dovresti essere in grado di eseguire Discourse direttamente dalla tua directory di origine utilizzando un container di sviluppo di Discourse.

:white_check_mark: Vantaggi: Nessuna necessità di installare dipendenze di sistema, nessuna configurazione richiesta per configurare rapidamente un ambiente di sviluppo.

:x: Svantaggi: Sarà leggermente più lento dell’ambiente di sviluppo nativo su Ubuntu e molto più lento di un’installazione nativa su MacOS.

Vedi anche Developing Discourse using a Dev Container

Passo 1: Installare 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

È possibile eseguire i comandi precedenti all’interno di WSL ma è necessario avere tutti i file all’interno del file system WSL. Ad esempio, funziona bene se si trova all’interno di ~/discourse ma fallisce se è posizionato all’interno di /mnt/c/discourse.

MacOS

:warning: L’immagine docker di sviluppo di Discourse è disponibile solo per architetture x86_64. Le Macchine M1 sono in grado di avviare l’immagine utilizzando l’emulazione dell’architettura, ma è improbabile che Discourse si avvii a causa della mancanza di supporto inotify in QEMU.

Invece, dovresti usare Install Discourse on macOS for development

Opzione 1: Scarica un .dmg pacchettizzato dallo store di Docker
Opzione 2: brew install docker

Passo 2: Avviare il Container

Clona il repository Discourse sul tuo dispositivo locale.

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

(dalla tua radice sorgente)

d/boot_dev --init
    # attendi mentre:
    #   - le dipendenze vengono installate,
    #   - il database viene migrato, e
    #   - viene creato un utente admin (dovrai interagire con questo)

# In un terminale:
d/rails s

# E in un terminale separato
d/ember-cli

…quindi apri un browser su http://localhost:4200 e voilà!, dovresti vedere Discourse.

Collegamenti simbolici dei Plugin

Il flusso di sviluppo Docker supporta i collegamenti simbolici sotto la directory plugins/, con la seguente avvertenza:

Ogni volta che viene creato un nuovo collegamento simbolico di un plugin, il container Docker deve essere riavviato con:

d/shutdown_dev; d/boot_dev

Note:

  • Per testare le email, esegui MailHog:

    d/mailhog
    
  • Se mancano delle gem, esegui:

    d/bundle install
    
  • Se è necessaria una migrazione del db:

    d/rake db:migrate RAILS_ENV=development
    
  • Quando hai finito, puoi scegliere di terminare il container Docker con:

    d/shutdown_dev
    
  • I dati vengono mantenuti tra le invocazioni del container nella directory tmp/postgres della tua radice sorgente. Se per qualsiasi motivo desideri reimpostare il tuo database, esegui:

    sudo rm -fr data
    
  • Se vedi errori come “permission denied while trying to connect to Docker”, esegui:

    run `sudo usermod -aG docker ${USER}`
    sudo service docker restart
    
  • Se desideri esporre globalmente le porte dal container alla rete (disattivato di default) usa:

    d/boot_dev -p
    
  • Il Dockerfile proviene da discourse/discourse_docker su GitHub, in particolare image/discourse_dev.

Esecuzione dei Test

d/rake autospec

Per eseguire test di plugin specifici, puoi anche fare qualcosa di simile:

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

O anche qualcosa di simile per essere ancora più specifico:

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

Questo documento è controllato in versione - suggerisci modifiche su github.

72 Mi Piace
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?
External database ENV VARs not documented (external PG Port, external Redis ENV VARs)
Discourse on local pc
Discourse developement environment setup
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
Which is the better option to self-host?
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'
Adding command line tools support for user api keys
Install plugins in your non-Docker development environment
Adding command line tools support for user api keys
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
Can't set up dev environment due to cppjieba_rb failing to install
Allow subscription of predetermined length
Cannot load any images “Uncaught (in promise) no-response: no-response”
Discovery document is missing
Discourse API developers docker-compose basic image
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
Installing discourse follow plugin in development (boot_dev) setup — no app.yml file
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?
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
Availability of OpenID Connect in hosted plans
Tags rearranged, triggering an extra edit
Migrate a phpBB3 forum to Discourse
OAuth2 and Microsoft ADFS
Install Discourse for Development using Docker is Failed
External database ENV VARs not documented (external PG Port, external Redis ENV VARs)
Install on macOS – Failure: Scheduler::Defer can pause and resume
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)
Install on macOS – Failure: Scheduler::Defer can pause and resume
How can I install Discourse on Windows? Getting restarting (100) error
Stuck in infinite loop in Mac terminal after source ~/.bashrc
I want to install a plugin for development, what should I do?
Can't set up dev environment due to cppjieba_rb failing to install
Total newbie struggling to preview the signup modal with my test theme, what am I missing?
Configure Discourse to use a separate PostgreSQL server
`script/osx_dev` script is pretty broken
Issue in setup discourse on ubuntu server
Bundle install fails after adding gem "mysql2" and gem "reverse_markdown"
Using a launcher built docker image in docker-compose
Developing Discourse using a Dev Container
Can't uninstall on Ubuntu 18.04
I want to install a plugin for development, what should I do?
Without any coding knowledge, is it possible to install and maintain Discourse?
Using a launcher built docker image in docker-compose
Discourse redirects to the OAuth server after loading `/?authComplete=true`
Hello from Gitpod! (installing on google cloud + automated dev setup)