Discourse InstantApp


#1

Would be pretty dandy to have :stuck_out_tongue:, considering this community also uses Discourse.

Tried to install it myself but I’m getting

while bootstrapping.

Using Docker version 1.3.0, build c78088f from here

Possibly related to


#2

The issue is Discourse uses a x64 base image. I’ll get a Discourse arm image made now :slight_smile:


#3

This topic is about discourse installation on C1 server

Install packages

Run these commands as root login

apt-get -y install build-essential libssl-dev libyaml-dev git libtool libxslt-dev libxml2-dev libpq-dev gawk curl pngcrush imagemagick vim software-properties-common redis-server postfix nginx postgresql postgresql-contrib

Install RVM

We recommend installing RVM isolated to a single user’s environment.

Create a new user

Run these commands as root login

adduser --shell /bin/bash --gecos 'Discourse user' discourse
install -d -m 755 -o discourse -g discourse /var/www/discourse

Change to the ‘discourse’ user:

sudo su - discourse

Install RVM

Run the commands as discourse user

Install RVM

\curl -s -S -L https://get.rvm.io | bash -s stable

Create the file ~/.rmvrc and add the following line

rvm_make_flags=( -j 4 )

Refresh your profile

. ~/.rvm/scripts/rvm

Install missing packages

Install necessary packages for building ruby rvm requirements

NOTE: rvm will tell you which packages you need to install during this step.

rvm --autolibs=read-fail requirements

Then as root login install missing packages, e.g

apt-get install libreadline6-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake bison pkg-config libffi-dev

Build and install ruby

Run the following command, it can take a few minutes

rvm install 2.0.0

Use installed ruby as default

rvm use 2.0.0 --default

Install bundler

gem install bundler

bundle config --global jobs 4

This topic is about discourse installation on C1 server

Install packages

Run these commands as root login

apt-get -y install build-essential libssl-dev libyaml-dev git libtool libxslt-dev libxml2-dev libpq-dev gawk curl pngcrush imagemagick vim software-properties-common redis-server postfix nginx postgresql postgresql-contrib

Install RVM

We recommend installing RVM isolated to a single user’s environment.

Create a new user

Run these commands as root login

adduser --shell /bin/bash --gecos 'Discourse user' discourse
install -d -m 755 -o discourse -g discourse /var/www/discourse

Change to the ‘discourse’ user:

sudo su - discourse

Install RVM

Run the commands as discourse user

Install RVM

\curl -s -S -L https://get.rvm.io | bash -s stable

Create the file ~/.rmvrc and add the following line

rvm_make_flags=( -j 4 )

Refresh your profile

. ~/.rvm/scripts/rvm

Install missing packages

Install necessary packages for building ruby rvm requirements

NOTE: rvm will tell you which packages you need to install during this step.

rvm --autolibs=read-fail requirements

Then as root login install missing packages, e.g

apt-get install libreadline6-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake bison pkg-config libffi-dev

Build and install ruby

Run the following command, it can take a few minutes

rvm install 2.0.0

Use installed ruby as default

rvm use 2.0.0 --default

Install bundler

gem install bundler

bundle config --global jobs 4

Install libv8 and therubyracer

Download the archieve containing libv8 and therubyracer for C1 server

wget https://fr-1.storage.online.net/stuff/libv8_therubyracer.tar
tar -xvf libv8_therubyracer.tar

Want to compile by yourself? follow this guide https://community.cloud.online.net/t/how-to-install-libv8-and-therubyracer-on-c1-server/320

Install libv8

cd /home/discourse/libv8

# Install GEM
bundle install
cd pkg && bundle exec gem install libv8-3.16.14.3-armv7l-linux.gem

Installing the rubyracer

cd /home/discourse/therubyracer

# Install GEM
bundle install
cd pkg && bundle exec gem install therubyracer-0.12.1.gem

Discourse installation

git clone git://github.com/discourse/discourse.git /var/www/discourse
cd /var/www/discourse

# To run on the most recent numbered release instead of bleeding-edge:
#git checkout latest-release

Discourse installation

git clone git://github.com/discourse/discourse.git /var/www/discourse
cd /var/www/discourse

# To run on the most recent numbered release instead of bleeding-edge:
#git checkout latest-release

Before executing the bundle install command edit the following discourse files:

Gemfile

-gem 'therubyracer'
+gem 'libv8', path: '/home/discourse/libv8'
+gem 'therubyracer', path: '/home/discourse/therubyracer'

Gemfile.lock

+PATH
+  remote: /home/discourse/libv8
+  specs:
+    libv8 (3.16.14.3)
+
+PATH
+  remote: /home/discourse/therubyracer
+  specs:
+    therubyracer (0.12.1)
+      libv8 (~> 3.16.14.0)
+      ref

-    libv8 (3.16.14.7)

-    therubyracer (0.12.1)
-      libv8 (~> 3.16.14.0)
-      ref

+  libv8!
+  therubyracer!

Then execute bundle install --no-deployment instead bundle install

Then execute bundle install --no-deployment or bundle install

Give Postgres database rights to the discourse user:

As root login execute the following command:

sudo -u postgres createuser -s discourse
# If you will be using password authentication on your database, only
# necessary if the database will be on a remote host
sudo -u postgres psql -c "alter user discourse password 'todayisagoodday';"

Configure Discourse

Run these commands as the discourse user

cd /var/www/discourse/config
cp discourse_quickstart.conf discourse.conf
cp discourse.pill.sample discourse.pill

Editing /var/www/discourse/config/discourse.conf

Database/Hostname:

change database username/password if appropriate
change hostname to the name you'll use to access the Discourse site, e.g. "forum.example.com"

Redis

no changes if this is the only application using redis, but have a look

E-mail

Browse through all the settings and be sure to add your mail server SMTP settings so outgoing mail can be sent (we recommend Mandrill) https://mandrillapp.com/

Editing: /var/www/discourse/config/discourse.pill

  • Change application name from ‘discourse’ if necessary
  • Ensure appropriate Bluepill.application line is uncommented

Initialize the database

# Run these commands as the discourse user
# The database name here should match the production one in database.yml
cd /var/www/discourse
createdb discourse_prod
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake assets:precompile

Nginx setup

Run these commands as root login

cp /var/www/discourse/config/nginx.global.conf /etc/nginx/conf.d/local-server.conf
cp /var/www/discourse/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf
rm /etc/sites-enabled/default
service nginx reload

Bluepill setup

# Run these commands as the discourse user
gem install bluepill
echo 'alias bluepill="NOEXEC_DISABLE=1 bluepill --no-privileged -c ~/.bluepill"' >> ~/.bash_aliases
rvm wrapper $(rvm current) bootup bluepill
rvm wrapper $(rvm current) bootup bundle

Start discourse

RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=2 bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill

Add the Bluepill startup to crontab.

# Run these commands as the discourse user
crontab -e

Then, add the following lines:

@reboot RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=2 /home/discourse/.rvm/bin/bootup_bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill

Configure postfix with mandrill (email)

Original install guide for discourse install is here https://github.com/discourse/discourse/blob/master/docs/INSTALL-ubuntu.md


#4

Maybe post it as a new post?

Possibly add tar xvf libv8_therubyracer.tar before “Install libv8”.

cd /var/www/vendor/gems/therubyracer is a wrong dir, it’s /home/discourse/therubyracer as you used cd /home/discourse/libv8 earlier.

Also maybe add a link to http://mandrill.zendesk.com/entries/23060367 as that shows folks how to set up mandrilla with postifx. :smile:

Thanks for the how-to.


#5

Thanks for the feedback @Moter8!

It’s fixed


#6

What is the status on this?

I imagine that you went with the ubuntu image and not with the docker one, don’t you?


#7

Yes, we are waiting for ruby libv8 contributors to fix the gem binary issue with libv8 on arm.
The source version of the gemfile are delivered instead of the binary.


http://rubygems.org/gems/libv8/versions/


#8

I got this. Is there a work-around available or do I have no other option than to wait?


#9

Some notes

I just ran gem install therubyracer --platform arm-linux (see Github issue) before bundle install and I did not run in any issues. However, in the end, I could to compile the assets. So therubyracer from rubygems is still broken.

I set the password of discourse to ‘*’ in the /etc/shadow to prohibit remote login.

When running the database migration, I got the error fe_sendauth: no password supplied. I changed the /etc/postgresql/9.4/main/pg_hba.conf as described in stackoverflow (md5 -> trust) and restarted the db sudo service postgresql restart.

RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake --trace db:migrate worked only after 3 consecutive attempts. I have played a little bit with bash piping to read the error output, but this should not have any influence on the ruby memory corruption/segfault I experienced before.

It must be m /etc/nginx/sites-enabled/default (nginx was missing). I restarted nginx, but it failed. I found mkdir() "/var/nginx/cache" failed (2: No such file or directory) in /var/log/nginx/error.log and created the directory by hand. mkdir /var/nginx. Afterwards, reload finishes with [OK].


#10

Can you please share your postfix main.cf file? I receive only mails from cron jobs using postfix. Mails from discourse are blocked for some reason:

(host smtp.mandrillapp.com[54.247.27.189] said: 421 4.4.2 ip-10-74-19-164 Error: timeout exceeded (in reply to end of DATA command))

#11

Outgoing mail in the trial is blocked.


#12

Well there is where I hit a wall too.

I ended up having a Discourse installation but being unable to log into it: labs.moter8.pw


#13

As far as I got it, the default mail ports are blocked, but Mandrill accepts port 2525 which is not blocked. I managed to send some mails over this port to Mandrill. I have the impression, that emails are accepted depending on the sender/recepient mail adress. Thus I would have been interested in the postfix config.

If you configured discourse to use your local postfix as a releay, you can inspect the mail queue with postqueue -p and read messages with postcat -q {MAIIL ID}. This way, I could confirm my mail and log in.


#14

I actually tried to do that too but it didn’t work at all. Setting up email stuff is a nightmare.


#15

I got it finally working. I ran into timout issues with mandrill. Now, I am using mailjet.com (French enterprise) on port 588 and it works like a charm. :smile:

However, the whole setup without docker is a mess. I ran now into troubles with google/twitter login and https. There is a spdy-related bug that redirects to a blank page.

To cite one of the core developers:

@XeonCore: Are your attempts to build an arm discourse docker image on github? I would like to help push things forward. :smile:


#16

I disabled spdy and now it’s working.

Short summary:

  • latest discourse beta (v1.2.0.beta4, commit 889aa92ade6cf621ebbdd9496605b1792d77a064)
  • mail with a postfix relay to port 588 of mailjet.com
  • ssl certificate
  • login with twitter or google (seems to work, not tested yet)
  • spdy disabled due to a nginx problem: ERR_SPDY_PROTOCOL_ERROR (blank page) when acccessing {discourse hostname}/auth/twitter (without spdy I get a temporay redirect to a twitter oauth)

#17

Your google OAUTH signup/login does not work yet, but thanks for the additional steps:


#18

Hi guys,

We are working to provide a docker image for discourse running on arm. Also, we are waiting for the following libv8 issue to be fixed.

Edouard


#19

Thanks for pointing out the issue. I spend enough time at https://meta.discourse.org that I new the solution (at least I hope so).

--- discourse.conf.ssl  2014-12-17 14:21:34.858172042 +0000
+++ discourse.conf.ssl2 2014-12-17 15:36:33.069996394 +0000
@@ -21,7 +21,7 @@
 
 # attempt to preserve the proto, must be in http context
 map $http_x_forwarded_proto $thescheme {
-  default $scheme;
+  # default $scheme;
   https https;
 }

It should work now. However, in this boards signup needs to be approved. :wink:


#20

That error message suggests its trying to redirect to port 80 using https…

https://forum.visionarys.club:80/

Obviously, that won’t work unless you are running SSL over port 80. Whilst this isn’t the exact issue, it provides you some insight into sorting out the mismatch in redirect URIs.