I think the virtualization support is really really new, not surprised it is a bit of an adventure.
I haven’t tried it yet.
If anyone is able to run Discourse using docker in a M1 Mac, please let me know. In the mean time, I’ll try to follow the other guide! Thank you!
I tried briefly today, and got stuck at the same step as you, but with an error:
Invalid gemspec in [/usr/local/lib/ruby/gems/2.7.0/specifications/default/zlib-1.1.0.gemspec]: Malformed version number string specification_version bundler: failed to load command: rake (/usr/local/bin/rake)
Yes, please do. There are multiple team members using Discourse on M1 (myself included) every day, so it works quite well!
Let us know if you run into any issues.
Thank you very much for your time and help! At least I’m not the only one stuck with it.
Hi, i think we should make a description about the Ember-CLI here, and a shourcut for below command without enter into docker container.
And i can’t get it work by execute above commands into container, seems container didn’t expose the 4200 port.
Manual expose the port 4200 by edit
After reboot container I access
localhost:4200 got this:
bin/ember-cli PORT to
9292 all working.
ember-cli bash unable work with
The Ember CLI is a new (and hard fought) development; @eviltrout should be able to comment on that soon.
Yes this will have to be updated. In the meantime you can disable that by setting the
NO_EMBER_CLI environment variable to
Probably obvious but could you clarify where you set the env variable @eviltrout ?
I tried in the d/unicorn file like this:
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD" -e NO_EMBER_CLI=1
…but that didn’t work (still getting " Ember CLI is Required in Development Mode" message at localhost:9292).
d/boot_dev -e NO_EMBER_CLI=1
I tried this today, and also ran into issues. The error I saw was because Docker’s architecture emulation doesn’t support
inotify (which we use a lot in Discourse development). For now, I’ve added a warning to
d/boot_dev when a non-x86_64 architecture is detected:
❯ d/boot_dev WARNING: Docker architecture is not x86_64. Discourse development is unlikely to work using Docker's architecture emulation. Please try a native development installation.
I’ve now added a
d/ember-cli helper, and forwarded port 4200 by default. The info at the top of this topis has also been updated. Once you’ve updated, run
d/rails s in one terminal, and
d/ember-cli in another. I’ve also set
NO_EMBER_CLI as one of the variables which is passed through to Docker, so that is available if needed.
@david probs inconsequential but just FYI: The boot_dev script prints out a false error finding on the x86_64 check when I accidentally ran without Docker on…(but the ‘Is the docker daemon running’ part is right)…
WARNING: Docker architecture is not x86_64. Discourse development is unlikely to work using Docker's architecture emulation. Please try a native development installation. ...(snip)... Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Thanks for this image, and the super-clear instructions!
psql: error: FATAL: Peer authentication failed for user "postgres" when running
data/postgres/ had all the authentication methods set to “trust”, there was another one in
/etc/postgresql/13/main/ which had the defaults (“peer” / “md5”).
/etc/postgresql/13/main/pg_hba.conf, changed all the methods to
d/shell and ran
sv restart postgres to pick up the changes – and was able to continue by running
d/bundle install; d/rake db:migrate RAILS_ENV=development; d/rake admin:create manually.
Leaving here in case it’s helpful for anyone else!
Thank you for the guide.
However I’m having issues with creating a backup from the admin section.
The error I’m getting is:
pg_dump: error: connection to database "discourse development" failed: FATAL: Peer authentication failed for user "postgres".
I checked the pg_hba.conf file, and have all options set to trust.
Would be great i could get some assistance on how to get this to work.
I tried on Ubuntu as well as on MacOSX. Everything is working fine on both (creating Posts, API…) except for the backup functionality.
Thanks for this fantastic docker solution.
For running plugin specs, this works nicely:
Is there a way to target specific plugin tests, as per a non-docker dev?, e.g.:
LOAD_PLUGINS=1 RAILS_ENV=test rspec plugins/discourse-follow/spec/requests/follow_controller_spec.rb:32
I’ve tried e.g.:
d/rspec plugins/discourse-follow/spec/lib/updater_spec.rb:10 LOAD_PLUGINS=1 RAILS_ENV=test
But getting an error.
RAILS_ENV must precede the command to assign environment variables. Following the command, they’re being treated as arguments to
rspec, which it doesn’t understand.
LOAD_PLUGINS=1 RAILS_ENV=test d/rspec plugins/discourse-follow/spec/lib/updater_spec.rb:10
No, I’m not convinced that works - have you actually tried it?
NameError: uninitialized constant Follow
I suspect this is because the environment variables are not being passed into the docker process?
That was why I was making them arguments.
Apologies, I misinterpreted your two commands as “the first works for this other spec, the second doesn’t work for this spec”. I don’t have a development environment set up to test.
Looking at the rspec file in Github, I think you’re right that it’s not passing in the environment variables. It looks like you should be able to run
d/shell to get a shell inside the container, then run your rspec command there though.
Simon, that’s more than an excellent useable workaround, thanks!
Just tried that and it works, ie:
my-blah-machine:~/discourse$ d/shell discourse@discourse:/src$ LOAD_PLUGINS=1 RAILS_ENV=test rspec plugins/discourse-follow/spec/lib/updater_spec.rb:37
Have added this and the whole plugin version to the Wiki
Taking a closer look at
d/exec, which both
d/rspec use, I think it can also be shortened like so:
RAILS_ENV=test d/exec LOAD_PLUGINS=1 rspec plugins/discourse-follow/spec/lib/updater_spec.rb:37
d/exec does pass in
RAILS_ENV but not
LOAD_PLUGINS, hence them being on either side of