2013-02-12 10:18:59 -06:00
# Discourse Advanced Developer Install Guide
2018-04-04 15:04:31 -05:00
This guide is aimed at advanced Rails developers who have installed their own Rails apps before.
2013-08-24 06:31:02 -05:00
Note: If you are developing on a Mac, you will probably want to look at [these instructions ](DEVELOPMENT-OSX-NATIVE.md ) as well.
2013-02-12 10:18:59 -06:00
2016-06-01 13:42:05 -05:00
# Preparing a fresh Ubuntu install
2018-09-30 23:28:16 -05:00
To get your Ubuntu 16.04 or 18.04 LTS install up and running to develop Discourse and Discourse plugins follow the commands below. We assume an English install of Ubuntu.
2016-06-01 13:42:05 -05:00
# Basics
whoami > /tmp/username
sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get -yqq update
2020-10-16 05:41:27 -05:00
sudo apt-get -yqq install software-properties-common vim curl expect debconf-utils git-core build-essential zlib1g-dev libssl-dev openssl libcurl4-openssl-dev libreadline6-dev libpcre3 libpcre3-dev imagemagick redis-server advancecomp jhead jpegoptim libjpeg-turbo-progs optipng pngcrush pngquant gnupg2
2016-06-01 13:42:05 -05:00
2021-11-22 11:16:35 -06:00
# oxipng
mkdir /tmp/oxipng-install & & cd /tmp/oxipng-install
wget https://github.com/shssoichiro/oxipng/releases/download/v5.0.1/oxipng-5.0.1-x86_64-unknown-linux-musl.tar.gz
tar -xzf oxipng-5.0.1-x86_64-unknown-linux-musl.tar.gz & & cd oxipng-5.0.1-x86_64-unknown-linux-musl
cp oxipng /usr/local/bin
2016-06-01 13:42:05 -05:00
# Ruby
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
2020-06-29 02:48:21 -05:00
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
2016-06-02 12:06:04 -05:00
curl -sSL https://get.rvm.io | bash -s stable
2016-06-01 13:42:05 -05:00
echo 'gem: --no-document' >> ~/.gemrc
2016-06-02 12:06:04 -05:00
2017-07-31 04:09:09 -05:00
# exit the terminal and open it again to activate RVM
2016-06-02 12:06:04 -05:00
2022-02-02 10:05:37 -06:00
rvm install 2.7.2
rvm --default use 2.7.2 # If this error out check https://rvm.io/integration/gnome-terminal
2021-10-05 05:18:06 -05:00
gem install bundler rake
2016-06-01 13:42:05 -05:00
2018-09-30 23:12:52 -05:00
# Download and install postgresql-10 from https://wiki.postgresql.org/wiki/Apt
2016-06-01 13:42:05 -05:00
# Postgresql
2017-10-03 09:25:08 -05:00
sudo -u postgres -i
createuser --superuser -Upostgres $(cat /tmp/username)
2016-06-01 13:42:05 -05:00
psql -c "ALTER USER $(cat /tmp/username) WITH PASSWORD 'password';"
2016-06-02 12:06:04 -05:00
exit
2013-02-12 10:18:59 -06:00
2016-06-01 13:42:05 -05:00
# Node
2017-07-31 04:09:09 -05:00
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
# exit the terminal and open it again to activate NVM
nvm install node
nvm alias default node
2017-12-19 01:59:41 -06:00
npm install -g svgo
2013-02-12 10:18:59 -06:00
2014-06-03 18:18:32 -05:00
2016-06-01 13:42:05 -05:00
If everything goes alright, let's clone Discourse and start hacking:
2014-06-03 18:18:32 -05:00
2016-06-01 13:42:05 -05:00
git clone https://github.com/discourse/discourse.git ~/discourse
cd ~/discourse
bundle install
2017-10-03 09:25:08 -05:00
# run this if there was a pre-existing database
bundle exec rake db:drop
RAILS_ENV=test bundle exec rake db:drop
# time to create the database and run migrations
2019-09-18 09:09:17 -05:00
bundle exec rake db:create
bundle exec rake db:migrate
2017-10-03 09:25:08 -05:00
RAILS_ENV=test bundle exec rake db:create db:migrate
2017-12-19 01:59:41 -06:00
2017-07-31 04:09:09 -05:00
# run the specs (optional)
bundle exec rake autospec # CTRL + C to stop
2017-12-19 01:59:41 -06:00
2017-07-31 04:09:09 -05:00
# launch discourse
bundle exec rails s -b 0.0.0.0 # open browser on http://localhost:3000 and you should see Discourse
2013-03-24 22:49:22 -05:00
2017-10-02 17:08:07 -05:00
Create an admin account with:
2014-07-01 09:12:52 -05:00
2017-10-02 17:08:07 -05:00
bundle exec rake admin:create
2014-07-01 09:12:52 -05:00
2017-10-03 09:25:08 -05:00
If you ever need to recreate your database:
bundle exec rake db:drop db:create db:migrate
bundle exec rake admin:create
RAILS_ENV=test bundle exec rake db:drop db:create db:migrate
2021-10-05 05:18:06 -05:00
Configure emails via MailHog (https://github.com/mailhog/MailHog):
docker run -p 8025:8025 -p 1025:1025 mailhog/mailhog # open http://localhost:8025 to see the emails
2016-06-01 13:42:05 -05:00
Discourse does a lot of stuff async, so it's better to run sidekiq even on development mode:
2013-03-24 22:49:22 -05:00
2017-07-25 01:55:22 -05:00
bundle exec sidekiq # open http://localhost:3000/sidekiq to see queues
2016-06-01 13:42:05 -05:00
bundle exec rails server
2013-03-24 22:49:22 -05:00
2016-06-01 13:42:05 -05:00
And happy hacking!