What is the latest recommended workflow for local development? (Ubuntu 16.04)

I’ve been searching around for the ideal way to develop a discourse site on my laptop (Ubuntu 16.04), but am unsure about the most current best practices. I’m new to Rails and am having trouble figuring out how to setup a local development environment for migration from Drupal, theme development, and plugin development.

Are people generally using their system’s environment, or Vagrant, or Docker?

If I do use my local environment, what is the general, recommended workflow for syncing code and data with the live, production Docker install?

Right. You want the Beginners Guide to Install Discourse on Ubuntu for Development

I’ve been doing this a year and I mostly don’t know. Here are some things I recommend:

  • Always work on a branch
  • git pull upstream master to re-sync with, uh, upstream

Oh. Perhaps this is what you want to know: To sync with production you make plugins. Create a repo for each and symlink it to the plugins directory.

You don’t ever, ever, ever, run your forked code in development.


Thanks. Do you have a system for truncating (or dropping and resetting) the databases while working? Right now I’m trying to create a bash script that will do it, but I’m not sure if someone has already solved this kind of problem.

Something like this (unfinished, non-working import script):

# Step 1
dropdb discourse_development
dropdb discourse_test
dropdb discourse_test_multisite

# Step 2
echo `whoami` > /tmp/username
sudo su - postgres

# Step 3
# createuser --createdb --superuser -Upostgres $(cat /tmp/username)
# psql -c "ALTER USER $(cat /tmp/username) WITH PASSWORD '$PASSWORD';"
psql -c "create database discourse_development owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test        owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test_multisite        owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -d discourse_development -c "CREATE EXTENSION hstore;"
psql -d discourse_development -c "CREATE EXTENSION pg_trgm;"
psql -d discourse_test -c "CREATE EXTENSION hstore;"
psql -d discourse_test -c "CREATE EXTENSION pg_trgm;"
psql -d discourse_test_multisite -c "CREATE EXTENSION hstore;"
psql -d discourse_test_multisite -c "CREATE EXTENSION pg_trgm;"

# Step 4
exit # postgres user
rails db:migrate

# To create an admin user
rake admin:create

# Run import script
export IMPORT=1
bundle install
RAILS_ENV=development bundle exec ruby script/import_scripts/drupal_7/importer.rb

Yeah that bash script is overdoing it a bit.

I use:

set -e

dropdb --if-exists discourse_development
dropdb --if-exists discourse_test
dropdb --if-exists discourse_test_multisite

createdb discourse_development
createdb discourse_test
createdb discourse_test_multisite

redis-cli flushall

bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:migrate


Thanks. I’ll try that. :slight_smile:

When I save the “about me” field on my local machine (Ubuntu 16.04), the UI says that it has been saved, but when I do a hard refresh of the page, the text is missing. Is there something else that has to be configured to get it to save that to the database?

Rails 5.1.3
Ruby 2.4.1p111
Postgres 9.5.9
Redis server 3.0.6

I can get to redis from irb. The local site seems to otherwise mostly work.

Have you done a git pull lately? That bug got fixed a while ago.

1 Like

Thanks, that was it. :slightly_smiling_face:

1 Like