I needed to run development discourse (set up following Beginners Guide to Install Discourse for Development using Docker ) using database from another container. To do so, I had to modify the installation steps as follows:
git clone https://github.com/discourse/discourse.git
cd discourse
-
vim config/database.yml
, on the top of the file, make it into:
development:
prepared_statements: false
adapter: postgresql
#database: <%= ENV['DISCOURSE_DEV_DB'] || 'discourse_development' %>
database: discourse
username: discourse
password: yourdbpassword
host: postgres
min_messages: warning
pool: 5
timeout: 5000
checkout_timeout: <%= ENV['CHECKOUT_TIMEOUT'] || 5 %>
host_names:
### Don't include the port number here. Change the "port" site setting instead, at /admin/site_settings.
### If you change this setting you will need to
### - restart sidekiq if you change this setting
### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`
- "localhost"
-
vim bin/docker/boot_dev
, find the line starting withdocker run
, and add a network definition matching the docker network to which your postgres container is attached to:docker run --network my-docker_network-name -d -p 4305:...
./bin/docker/boot_dev
./bin/docker/unicorn
- you may need to run migrations:
docker exec -it discourse_dev /bin/bash -c "cd /src; ./bin/rails db:migrate RAILS_ENV=development"
- visit http://localhost:9292/ and log in with credentials you set up earlier on that database
Is there a simpler way to do it, just with environment variables?