discourse-compose
discourse-compose copied to clipboard
Discourse for docker compose and rancher compose. https://github.com/leopku/discourse-compose
Discourse for docker compose and rancher compose
https://github.com/leopku/discourse-compose
WHY this project born?
A set of tools for docker were shipped with offical Discourse docker release. It do many things for user to check if Discourse can run correctly in docker and run correctly.
The main shortcoming of offical release is rebuilding, rebuilding, rebuilding. Anything changed must rebuild Discourse image. Rebuilding would take a so long time and our forum can't serve our users while rebuilding. It is not acceptable for our site.
The second thing made me to write a compose version for building a Discourse site is now we were using Rancher - a Platform for Operating Docker in Production - to manager all my services. After many times failured trying to run official release under rancher, I gave it up.
The last one is I need some mirrors for faster accessing and faster rebuilding. I should make these mirrors configurable.
After digging deep into what had offical release done while booting Discourse, I found another road to the same goal.
Contributing
- Send a Pull Request with your awesome new features and bug fixes.
- Be a part of the community and help resolve issues
- Support the development of this project with a donation through wechat
FAQ
How to make build and run faster?
- Clone Discourse source code to local and update it frequently.
- If you are in China, you can clone the source code from one of some mirrors like https://git.coding.net/leopku/discourse.git.
- If your chose cloning inside container, you can set
DISCOURSE_GIT_REPO
env. - Use a faster gem source by setting
GEM_SOURCE
env.https://mirrors.tuna.tsinghua.edu.cn/rubygems/
is a choice for chinese user.
How to configure environment variables?
- Copy
env.example
to.env
- Modify or add any environment variables as you want
What is mail container?
For many guys who first launch this awesome forum, smtp and mail problems may prevent their steps.
So I add a mail container base on mailhog - which is a fake mail server and provides a webui to show recieved emails.
This means you can easily do a preview setup with no actual smtp && email account with my default compose file.
BUT when in production, you MUST change DISCOURSE_SMTP_ADDRESS
setting. You can also comment the mail container in production.
How to add a plugin without rebuilding?
-
cd
volumes/discourse/plugins
and put source code of the plugin you desired in this folder -
cd
volumes/discourse/tmp/run
and delete these two file.db_migrated
and.assets_precompiled
-
run
docker-compose restart app
.For advanced user, run
docker-compose exec app /bin/bash
, then manualy do db migrate and assets precompiling.cd /var/www/discourse HOME=/home/discourse USER=discourse exec chpst -u discourse:www-data -U discourse:www-data bundle exec rake db:migrate HOME=/home/discourse USER=discourse exec chpst -u discourse:www-data -U discourse:www-data bundle exec rake assets:precompile sv restart unicorn
How to change nginx config without rebuilding?
- Change config file in
volumes/nginx/nginx.conf
andvolumes/nginx/conf.d/discourse.conf
-
docker-compose exec app /bin/bash
-
sv restart nginx
Quick start
-
Prerequisites
docker
anddocker-compose
must installed. -
Get source code of this project
git clone https://github.com/leopku/discourse-compose.git cd discourse-compose
-
Get source code of discourse. Choose ONE way followed,
- clone source code into Docker host (Recommended)
git clone https://github.com/discourse/discourse.git app/source/discourse git remote set-branches --add origin tests-passed
- clone source code into docker images by commenting Line18 and uncomment Line19 of
app/Dockerfile
. The result may look like this,
15 ######## 16 # Uncomment next line for speed up 17 ######## 18 # ADD ${DISCOURSE_SOURCE_PATH} /var/www/discourse 19 git clone --single-branch --depth=1 --branch v${DISCOURSE_VERSION} ${DISCOURSE_GIT_REPO}
We recommend first way. You could update only changed files but not hole code every time and only do rebuilding after updating is ready. It can fast your rebuilding and make your site back to online quickly.
-
Prepare plugins
3.1 prepare default plugins
cp -r app/source/discourse/plugins/* volumes/discourse/plugins/
3.2 prepare any plugin you wanted
cd volumes/discourse/plugin git clone https://github.com/discourse/docker_manager.git git clone https://github.com/discourse/discourse-solved.git ...
-
Prepare environment and config files
cp env.example .env cp volumes/nginx/nginx.conf.example volumes/nginx/nginx.conf cp volumes/nginx/conf.d/discourse.conf.example volumes/nginx/conf.d/discourse.conf
Check every environment variables in IMPORTANT section to meet your actual environment
-
Run
docker-compose up -d
-
Enjoy
Visit http://YOUR_DOCKER_HOST_IP:10080 and have fun.
TODOs
- [ ] Customized config parameter or file for Redis container
- [ ] Enable brotli
- [x] Version 1 format yml for rancher compose
License
MIT