Skip to content

Instantly share code, notes, and snippets.

@siddMahen
Last active June 8, 2020 13:36
Show Gist options
  • Save siddMahen/cf8689fe19e239536a7e946825b07f7f to your computer and use it in GitHub Desktop.
Save siddMahen/cf8689fe19e239536a7e946825b07f7f to your computer and use it in GitHub Desktop.
Coauthor setup instructions

Setting up Coauthor on a new Lighsail instance

Setup: Ubuntu 14.04 Lightsail instance with static IP address, DNS type A record linking the static IP to domain name (ravivakil.org)

  1. SSH into the server by running $ ssh -i /path/to/private/key ubuntu@ravivakil.org
  2. Securely move the private key onto the server (is this safe?) $ scp -i /path/to/private/key /path/to/private/key ubuntu@ravivakil.org:home/ubuntu/
  3. Install node.js, version 12.x.x (see https://github.com/nodesource/distributions/blob/master/README.md) by running $ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - followed by $ sudo apt-get install -y nodejs
  4. Download meteor by running $ curl https://install.meteor.com/ | sh
  5. Download Coauthor via git by running $ cd ~ && git clone https://github.com/edemaine/coauthor.git. Also create a build directory for later: $ cd ~ && mkdir coauthor-build
  6. Setup SSL certificates by following the instructions here: https://certbot.eff.org/lets-encrypt/ubuntuxenial-other
  7. Enter the deploy directory by running $ cd ~/coauthor/.deploy
  8. Modify the mup.js file so it looks like:
module.exports = {
  servers: {
    one: {
      host: 'ravivakil.org',
      username: 'ubuntu',
      pem: "/home/ubuntu/privatekey.pem"
    }
  },
  // Meteor server
  meteor: {
    name: 'coauthor',
    //path: '/home/ubuntu/coauthor',
    path: '../',
    servers: {
      one: {}
    },
    docker: {
      image: 'abernix/meteord:node-12-base',
      stopAppDuringPrepareBundle: false,
    },
    buildOptions: {
      serverOnly: true,
      buildLocation: '/home/ubuntu/coauthor-build'
    },
    env: {
      ROOT_URL: 'https://ravivakil.org',
      MAIL_URL: 'smtp://email-smtp.us-west-2.amazonaws.com:587',
      //MAIL_FROM: 'coauthor@coauthor.csail.mit.edu',
      MONGO_URL: 'mongodb://mongodb/meteor',
      MONGO_OPLOG_URL: 'mongodb://mongodb/local',
      NODE_OPTIONS: '--trace-warnings'
    },
    deployCheckWaitTime: 200,
    deployCheckPort: 80,
    enableUploadProgressBar: true
  },

  // Mongo server
  mongo: {
    oplog: true,
    port: 27017,
    servers: {
      one: {},
    },
  },

  // Reverse proxy for SSL
  proxy: {
    domains: 'ravivakil.org',
    ssl: {
      crt: '/etc/letsencrypt/live/ravivakil.org/fullchain.pem',
      key: '/etc/letsencrypt/live/ravivakil.org/privkey.pem',
      forceSSL: true,
    },
    clientUploadLimit: '0', // disable upload limit
    nginxServerConfig: '../.proxy.config',
  },

  // Run 'npm install' before deploying, to ensure packages are up-to-date
  hooks: {
    'pre.deploy': {
      localCommand: 'npm install'
    }
  },
};
  1. Run sudo mup setup

Output:

Started TaskList: Setup Docker
[ravivakil.org] - Setup Docker
[ravivakil.org] - Setup Docker: SUCCESS

Started TaskList: Setup Meteor
[ravivakil.org] - Setup Environment
[ravivakil.org] - Setup Environment: SUCCESS

Started TaskList: Setup Mongo
[ravivakil.org] - Setup Environment
[ravivakil.org] - Setup Environment: SUCCESS
[ravivakil.org] - Copying Mongo Config
[ravivakil.org] - Copying Mongo Config: SUCCESS

Started TaskList: Start Mongo
[ravivakil.org] - Start Mongo
[ravivakil.org] - Start Mongo: SUCCESS

Started TaskList: Setup proxy
[ravivakil.org] - Setup Environment
[ravivakil.org] - Setup Environment: SUCCESS
[ravivakil.org] - Pushing the Startup Script
[ravivakil.org] - Pushing the Startup Script: SUCCESS
[ravivakil.org] - Pushing Nginx Config Template
[ravivakil.org] - Pushing Nginx Config Template: SUCCESS
[ravivakil.org] - Pushing Nginx Config
[ravivakil.org] - Pushing Nginx Config: SUCCESS
[ravivakil.org] - Cleaning Up SSL Certificates
[ravivakil.org] - Cleaning Up SSL Certificates: SUCCESS
[ravivakil.org] - Copying SSL Certificate Bundle
[ravivakil.org] - Copying SSL Certificate Bundle: SUCCESS
[ravivakil.org] - Copying SSL Private Key
[ravivakil.org] - Copying SSL Private Key: SUCCESS
[ravivakil.org] - Setup SSL Certificates for Domains
[ravivakil.org] - Setup SSL Certificates for Domains: SUCCESS
[ravivakil.org] - Configure Nginx Upstream
[ravivakil.org] - Configure Nginx Upstream: SUCCESS

Started TaskList: Start proxy
[ravivakil.org] - Start proxy
[ravivakil.org] - Start proxy: SUCCESS

Next, you should run:
    mup deploy
  1. Run mup deploy

Output (edited for brevity)

> Running hook default.deploy "npm install"

> coauthor@1.0.0 postinstall /home/ubuntu/coauthor
> node node_modules/grunt/bin/grunt --gruntfile .Gruntfile.coffee

...

Done.
audited 357 packages in 6.768s

4 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Building App Bundle Locally
Browserslist: caniuse-lite is outdated. Please run next command `npm update`

Started TaskList: Pushing Meteor App
[ravivakil.org] - Pushing Meteor App Bundle to the Server
[ravivakil.org] - Pushing Meteor App Bundle to the Server: SUCCESS
[ravivakil.org] - Prepare Bundle
[ravivakil.org] - Prepare Bundle: SUCCESS

Started TaskList: Configuring App
[ravivakil.org] - Pushing the Startup Script
[ravivakil.org] - Pushing the Startup Script: SUCCESS
[ravivakil.org] - Sending Environment Variables
[ravivakil.org] - Sending Environment Variables: SUCCESS

Started TaskList: Start Meteor
[ravivakil.org] - Start Meteor
[ravivakil.org] - Start Meteor: SUCCESS
[ravivakil.org] - Verifying Deployment
[ravivakil.org] - Verifying Deployment: SUCCESS

The MAIL_URL is set to a dummy value; a working Postfix server is also running on this machine (it is connected to Amazon's mail service), but I'd like to use Amazon's SMTP server directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment