Installa Discourse per lo sviluppo usando Docker

From my Ubuntu VM I was able to ping rubygems.org. I don’t know if there’s a way to check if the docker container can. I think I only pinged the http version, not https, though. Mentioning in case the problem is related to that. (One of the pages I saw when googling suggested changing https to http, but it’s not like I can do that since the defined behavior is somewhere in the docker container.)

1 Mi Piace

I’ve tried the MacOS options.

First using Option 2, Homebrew. I ran into issues though as not all dependencies were installed using the command of this guide. A complete one-by-one guide to install Docker on your Mac OS using Homebrew helped me getting a bit further.

I’m now stuck at Step 2 d/boot_dev --init:

Migrating database...

rake aborted!

PG::ConnectionBad: could not connect to server: No such file or directory

Is the server running locally and accepting

connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

/src/lib/site_settings/db_provider.rb:61:in `table_exists?'

/src/lib/site_settings/db_provider.rb:16:in `all'

/src/lib/site_settings/defaults_provider.rb:29:in `db_all'

/src/lib/site_setting_extension.rb:277:in `block in refresh!'

/src/lib/site_setting_extension.rb:274:in `synchronize'

/src/lib/site_setting_extension.rb:274:in `refresh!'

/src/lib/site_setting_extension.rb:495:in `block in setup_methods'

/src/config/initializers/004-message_bus.rb:120:in `<main>'

/src/config/environment.rb:7:in `<main>'

/usr/local/bin/bundle:23:in `load'

/usr/local/bin/bundle:23:in `<main>'

Tasks: TOP => db:migrate => db:load_config => environment

(See full trace by running task with --trace)

I’ve then downloaded the .dmg file but as I’m new to Docker, I don’t understand what to do from there. It would be great to have a little more detailed description of the macOS option.

Thanks.

1 Mi Piace

On MacOS, once you install Docker from the .dmg, just make sure it’s running — there should be an icon on the MacOS toolbar that you can use to check its status. Then literally follow the steps on the first post (clone, etc). Post here if you hit a problem going that route.

Mind, if you have installed docker with Homebrew before, it may be a good idea to uninstall that docker first or at least making sure that one is not running. I never installed docker with homebrew, so can’t advise there.

2 Mi Piace

Thanks.

I’ve used the icon and opened the Docker dashboard. I didn’t find any containers running there on the command line I could see multiple containers running though. I was wondering if I had to sign in to use Docker dashboard? Or maybe this behaviour occurs since there are multiple versions of Docker installed Homebrew and Desktop (.dmg)?

In the meantime I’ve managed to setup Discourse on DigitalOcean which works without problems and is okay for my purposes.

1 Mi Piace

The DMG installs docker, not discourse. It won’t add any containers initially.

From there you can follow the docker guide.

2 Mi Piace

When running the above command (on a Mac) I get this error:

An error occurred while installing cppjieba_rb (0.3.3), and Bundler cannot continue.

Make sure that `gem install cppjieba_rb -v '0.3.3' --source 'https://rubygems.org/'` succeeds

before bundling.

Do you have any suggestions? I don’t understand exactly what the problem is. The separate gem install doesn’t work either (even with sudo).

Also, why do gems have to be installed when I’m running a docker image? That should have been fully pre-installed already, right?

UPDATE: FIXED

I cloned to ~/repos/discourse but should have been to ~/discourse. Works like a charm now.

3 Mi Piace

If you get this error when running d/unicorn:

Could not find aws-partitions-1.284.0 in any of the sources
Run `bundle install` to install missing gems.

you can fix this by running:

docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "cd /src && USER=discourse RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RAILS_ENV=${RAILS_ENV:=development} bundle install"

after which d/boot_dev will run succesfully.

3 Mi Piace

Simpler

d/boot_dev
d/bundle install

We have helpers for all the usual tasks.

5 Mi Piace

In the OP it reads

The Docker development flow supports symlinks under the plugins/ directory

What do we symlink the plugins directory to in this context? Thanks!

1 Mi Piace
cd plugins
ln -s /full/path/to/your/plugin .
ln -s ~/src/my-great-plugin # for example
6 Mi Piace

Ah thanks just meaning to symlink to the plugins directory in this context.

1 Mi Piace

Generally you don’t symlink an entire directory for this workflow as you would normally want granular control over which plugins were in scope during a run.

4 Mi Piace

Ciao, sto seguendo questa guida e funziona bene, ma la mia preoccupazione è che ogni volta che eseguo d/boot_dev inizia a scaricare varie cose. Come posso scaricare una volta sola i file necessari e conservarli per il prossimo avvio? Il mio sistema operativo è Ubuntu 20.04.

1 Mi Piace

Ho provato a installare su un sistema Mint 20 appena formattato. Docker è disponibile:

terrapop@terrapop:/var$ docker version
Client: Docker Engine - Community
 Version:           19.03.12

terrapop@terrapop:/var/discourse$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset>
     Active: active (running) since Mon 2020-08-24 19:03:48 CEST; 31min ago

Poi ho clonato Discourse:

sudo git clone GitHub - discourse/discourse_docker: A Docker image for Discourse · GitHub /var/discourse
cd /var/discourse

Tuttavia, l’esecuzione di d/boot_dev --init ha portato a:

d/boot_dev --init

bash: d/boot_dev: File o directory non trovati

Qualcuno può aiutarmi?

1 Mi Piace

Aggiornamento: Ho appena aggiunto le nostre chiavi API di SendGrid all’app.yml e avviato l’app tramite ./launcher; ora funziona su localhost. Potrebbe essere che tutti i comandi d/ nel post originale siano obsoleti? Comunque, non riesco a capire. L’app ora è in esecuzione su Docker sul mio computer Ubuntu (Mint) in localhost, proprio come sull’ambiente di staging di Digital Ocean. Vogliamo sviluppare in locale con l’app in esecuzione tramite Docker e symlink per i plugin, ma non sono sicuro che sia pronta come dovrebbe, dato che non riesco a eseguire quei comandi d/ in alcun modo. Qualcuno può dare una mano? Grazie.

Aggiornamento: Colpa mia. Ho usato il link git per la produzione:

git clone GitHub - discourse/discourse_docker: A Docker image for Discourse · GitHub /var/discourse

Invece di:

git clone GitHub - discourse/discourse: A platform for community discussion. Free, open, simple. · GitHub

:cowboy_hat_face:

Tuttavia…

Ora ho nuovi problemi. Posso clonare solo in /var come superutente/root su Ubuntu Mint 20 (UID 0). Quindi, quando clono ed eseguo d/boot_dev --init, tutto si scarica e parte correttamente, ma in una fase successiva lo script genera un errore di permessi perché si aspetta di eseguire qualcosa con UID 1000, che è il primo utente creato su Mint, ovvero il mio account personale (terrapop), e non root. Come posso risolvere questo problema?

Soluzione: Più semplice di quanto pensassi. Basta creare una nuova directory www in var. Cambiare proprietario e permessi della directory www al primo utente su Mint e procedere come nei post dell’autore originale. Ora funziona. Felice.

2 Mi Piace

Per qualche motivo, i collegamenti simbolici alle directory sorgente dei miei plugin non funzionavano e ho dovuto spostare/copiare manualmente le directory sorgente dei plugin nella directory plugins per farli apparire in /admin/plugins dopo il riavvio del contenitore Docker.

Forse c’è stato un cambiamento nel modo in cui Docker supporta i collegamenti simbolici? Sto eseguendo docker-ce 19.03.12 su Ubuntu.

1 Mi Piace

Anche io ho sperimentato questo di recente con Docker Desktop per Mac.

1 Mi Piace

Ho eseguito gli stessi passaggi su un droplet DO da $5. Tutto è andato bene. Ora, come espongo il mio sito per poterlo accedere?

P.S. Funziona con ngrok. Non funziona ancora con il reverse proxy nginx sulla porta 9292

Grazie a questo. Puoi farlo direttamente sul server ed evitare di configurare il reverse proxy nginx. Sto godendo della configurazione d/o con docker+vscode remoto :slight_smile:

Usa d/unicorn -D per eseguire unicorn come demone, in modo che la shell rimanga utilizzabile dopo l’avvio del server.

Inoltre, hai bisogno di almeno un droplet d/o da $10.

3 Mi Piace

Sono su un Mac con zsh (su iTerm2) e, quando provo a utilizzare un collegamento simbolico per lo sviluppo di plugin, mi blocco con questi errori:

readlink: opzione non valida -- f
utilizzo: readlink [-n] [file ...]

Questo perché l’implementazione del comando readlink su Mac è leggermente diversa da quella GNU.

Il modo più semplice per risolvere è fare quanto segue:

# brew install coreutils
# ln -s "$(which greadlink)" "$(dirname "$(which greadlink)")/readlink"

Questo ti permetterà di utilizzare una versione compatibile di readlink.

Ricorda che devi avere il valore dirname "$(which greadlink)" nella tua variabile PATH in una posizione precedente a /usr/bin (dove si trova solitamente il readlink originale). Nel mio caso, PATH è qualcosa come /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:... e il collegamento simbolico a greadlink si trova in /usr/local/bin.

Riferimento: Fixing "readlink: illegal option -- f" error on a Mac

5 Mi Piace

Per eseguire una suite di test per un singolo plugin, puoi procedere in questo modo:

# d/rake "plugin:spec[NOME_PLUGIN]"
1 Mi Piace