Beginners Guide to Install Discourse for Development using Docker

Developing using Docker

Since Discourse runs in Docker, you should be able to run Discourse directly from your source directory using a Discourse development container.

:white_check_mark: Pros: No need to install any system dependencies, no configuration needed at all for setting up a development environment quickly.

:x: Cons: Will be slightly slower than the native dev environment on Ubuntu, and much slower than a native install on MacOS.

Step 1: Install 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

MacOS

Option 1: Download a packaged .dmg from the Docker store
Option 2: brew install docker

Step 2: Start Container

Clone Discourse repository to your local device.

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

(from your source root)

d/boot_dev --init
    # wait while:
    #   - dependencies are installed,
    #   - the database is migrated, and
    #   - an admin user is created (you'll need to interact with this)

d/unicorn
    # start rails server with sidekiq

or 


d/unicorn -x
    # start rails server without sidekiq

… then open a browser on http://localhost:9292 and voila!, you should see Discourse.

Plugin Symlinks

The Docker development flow supports symlinks under the plugins/ directory, with the following caveat:

Whenever a new plugin symlink is created, the Docker container must be restarted with:

d/shutdown_dev; d/boot_dev

Notes:

  • When you’re done, you can choose to kill the Docker container with:

    d/shutdown_dev
    
  • Data is persisted between invocations of the container in your source root tmp/postgres directory. If for any reason you want to reset your database run:

    sudo rm -fr data
    
  • If you see errors like “permission denied while trying to connect to Docker”, Run:

    run `sudo usermod -aG docker ${USER}` 
    sudo service docker restart
    
  • If you wish to globally expose the ports from the container to the network (default off) use:

    d/boot_dev -p
    
  • The Dockerfile comes from discourse/discourse_docker on GitHub, in particular image/discourse_dev.

Running Tests

d/rake autospec
30 Likes
HOWTO Set up a development environment using vagrant (Ubuntu guide)
IDE and comfortable DEV environment for newbies
Beginners Guide to Install Discourse on Ubuntu for Development
Using a launcher built docker image in docker-compose
MailCatcher not catching email
Docker install on MacOS
Running Discourse with a separate PostgreSQL server
Install Discourse for Development using Docker is Failed
External database ENV VARs not documented (external PG Port, external Redis ENV VARs)
External database ENV VARs not documented (external PG Port, external Redis ENV VARs)
Permission denied during Ubuntu developer setup
Qunit in Docker
Stuck in infinite loop in Mac terminal after source ~/.bashrc
Issue in setup discourse on ubuntu server
`script/osx_dev` script is pretty broken
Discourse redirects to the OAuth server after loading `/?authComplete=true`
Can't set up dev environment due to cppjieba_rb failing to install
Discourse API developers docker-compose basic image
Adding command line tools support for user api keys
Adding command line tools support for user api keys
Can't set up dev environment due to cppjieba_rb failing to install
Without any coding knowledge, is it possible to install and maintain Discourse?
Using a launcher built docker image in docker-compose
Using a launcher built docker image in docker-compose
Dev Category sidebar
[Resolved] Recent change breaks connectivity in Docker (+ non-Docker)
OAuth2 and Microsoft ADFS
Beginners Guide to Install Discourse on Ubuntu for Development
How to Install Discourse on LocalHost in Windows?
Unicode (Russian) username validation fails randomly
Hello from Gitpod! (installing on google cloud + automated dev setup)
Importing from phpBB3
I want to install a plugin for development, what should I do?
I want to install a plugin for development, what should I do?

This is really easy to get set up! Thanks.

I’m surprised, however, by how slow the local installation is. Is there a way to adjust the container specs somehow? I’d expect a slowdown, but maybe not one so dramatic…

Thanks again.