Self Hosting with Docker

These instructions make the following assumptions:

  • You've just finished setting up a Linux server (say, Ubuntu 16.04 64-bit) and have installed Docker on it.
  • You've configured your security groups to allow for incoming SSH connections from your local IP.
  • You've configured a domain name (or subdomain) to point to your server's IP address.
  • You've configured the DNS to enable HTTPS for your domain (say, using Cloudflare).

Getting started

  1. SSH into your new server:
   $ ssh -l {user} {IP to the server}
  1. Update your system:
   $ sudo apt-get update
   $ sudo apt-get upgrade
  1. Install Git:
   $ sudo apt-get update
   $ sudo apt-get install -y git
  1. Make sure you are in your home directory and clone the Standard File ruby-server project:
   $ cd ~
   $ git clone https://github.com/standardfile/ruby-server.git
   $ cd ruby-server
  1. Create .env.{app|db}.production files in the project's Docker environment directory:
   $ cd $PROJECT_ROOT/docker/environments/
   $ cp .env.app.producion.template .env.app.production
   $ cp .env.db.producion.template .env.db.production

Ensure that the .env.app.production file contains the below environment variables:

   $ cat .env.app.production
   RAILS_ENV=production
   SECRET_KEY_BASE=use "bundle exec rake secret"
   RAILS_SERVE_STATIC_FILES=true

   DB_CONNECTION=mysql
   DB_HOST=db
   DB_DATABASE=standardfile
   DB_USERNAME=root
   DB_PASSWORD=

Ensure that the .env.db.production file contains the below environment variable:

   $ cat .env.db.production
   MYSQL_ROOT_PASSWORD=

If you set a password for the root database user under DB_PASSWORD in .env.db.production, you must set the same password under MYSQL_ROOT_PASSWORD in .env.db.production.

  1. Build the services without starting them:
   $ docker-compose build
  1. Run the app service to compile the assets:
   $ docker-compose -f docker-compose.yml -f docker-compose.production.yml up app -d
   $ docker-compose exec app bundle exec rake assets:precompile

At this point the precompiled assets are stored in the public/
folder of the host. The Nginx container will mount the folder as a volume
and get the assets.

   $ docker-compose down
  1. Start the services:
   $ docker-compose -f docker-compose.yml -f docker-compose.production.yml up -d
  1. Login to the app service to initialize the project:
   $ docker-compose exec app bundle exec rake db:create db:migrate
  1. Access the server locally:

    $ curl {domain name}
    <!doctype html>
    <html>
      ...
      <body>
        <h1> Hi! You're not supposed to be here. </h1>
    
        <p> You might be looking for the <a href="https://app.standardnotes.org"> Standard Notes Web App</a> or the main <a href="https://standardnotes.org"> Standard Notes Website</a>. </p>
    
      </body>
    </html>
    
  2. You're done!

Using your new server

You can immediately start using your new server by using the Standard Notes app at https://app.standardnotes.org.

In the account menu, choose Advanced Options when signing in to specify your server.

Then, register for a new account, and begin using your private new secure Standard File server!