Merefield's Dev-in-the-Cloud Setup

  • It’s basically https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727?u=merefield on a cloud VPS without docker.

  • The VPS is fairly beefy at 4GB/4 Core … but it’s my daily driver so I don’t really want to economise here, but you could to lower costs.

  • I use rbenv to maintain the current version of Ruby

  • I git pull at start of each session to make sure I’m developing on the current master of Discourse.

  • I maintain a DNS entry to it and manually recertify to keep the https link working (so I don’t need to use other tools for developing with https)

  • I’ve made edits to the nginx discourse config to route the 443 calls. I symlink the sites-enabled so I can switch to running other configs for eg other apps

  • I symlink the plugins from a larger code directory.

  • VSCode lives on the client (my home work PC) and connects with an ssh tunnel. Standard stuff.

  • I also interact with it via Windows Terminal app. Optional.

I’ve also installed the cloud based VSCode so you can also dev entirely from a browser (for example, on an iPad), but that’s got some annoying limitation so don’t use it that way often.

Alright, so I followed this path for setting up my discourse developing environments. I started by creating an Ubuntu droplet at Digital Ocean (their $10/mo option). From there, I followed the steps from Beginners Guide to Install Discourse on Ubuntu for Development - developers - Discourse Meta, which @merefield linked to, above.

Everything seemed to work fine until the setup guide stated I could see my discourse forum on the localhost – how do I do that? I skipped this step and successfully created an admin account. Then, once I ran mailcatcher, this is what I was told:

Starting MailCatcher
==> smtp://127.0.0.1:1025
/root/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.5.1/lib/thin/server.rb:104: warning: constant ::Fixnum is deprecated
==> http://0.0.0.0:1080/
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.

Does this look alright? The guide stated that I run mail catcher like this:

mailcatcher --http-ip 0.0.0.0

Should I have replaced the zeros with my droplets numbers?

You should be running that command on your server in the ssh terminal session: afterall you trying to catch the emails sent by the server, not your client machine.

I believe the option simply prompts mailcatcher to share its interface over the internet so you can see the emails in a client browser on that port (1080 in this case). Try leaving it out and you should find you can’t see emails on your remote client browser.

Note that is insecure, so don’t send anything private over test emails, and only use mailcatcher when you need to (it’s only needed when you need to test emails for some reason!)

There’s a post about making mailcatcher secure here:

https://serverfault.com/questions/310060/how-to-serve-mailcatcher-behind-https-and-authentication

Thanks! Now that my discourse instance appears to be setup with an admin user, how can I see it from the front end? The meta post I followed for setup stated I could access via the local host – how do I do that? I’m very sorry for my ignorance here.

Simple:

  1. Run the Discourse server:

UNICORN_BIND_ALL=true bundle exec rails server

  1. …and put the IP of your Cloud server in the browser.

When I run the discourse server ( UNICORN_BIND_ALL=true bundle exec rails server) it runs for close to 30mins before the terminal appears to freeze. If during that time I place the IP in my (firefox) browser, I get this:

Screen Shot 2021-01-28 at 9.18.04 AM

Now, if I add :3000 after the IP, I don’t get that error message, but rather it appears to try to open the discourse site, but it never does. It even sometimes shows “discourse” on the browser tab.

Screen Shot 2021-01-28 at 9.21.02 AM

It shows an insecure connection icon – is this why I can’t get frontend access, or does it have something to do with the terminal running forever and then appearing to freeze up?

Any thoughts?

  1. The server should run forever until you stop it. It’s a server!
  2. Probably appearing to stop because you haven’t given it any more to do.
  3. The link will be insecure unless you choose otherwise
  4. You might need to make sure site_settings.yml is correctly configured - especially the port number.

FYI this wasn’t meant to be an exhaustive topic on how to set up a dev environment in the cloud - just an overview :wink:

Got it. I’ll fall back.

I don’t have time to go into detail on this but you also need to potentially consider the discourse file in:

/etc/nginx/sites-available

which should be symlinked in

/etc/nginx/sites-enabled

This is the file which will ensure requests on one port externally are routed to the discourse server that might be running on 3000.

There’s lots of detail online about how to set that up.

Mine is a bit more complex as I have other services running and also have a Domain Name for my dev server set up.

the other useful command to debug such stuff is this:

lsof -wni tcp:3000

which will list your discourse server processes if they are running

You can use this list to manually kill them if you need to (kill -9 PID)