This is a working instructional to deploy an app with the following (as of January 8th, 2017):
- DigitalOcean Ubuntu 16.04
- Meteor 1.4.2.3
- MUP (not MUPX)
The following are missing from this instructional:
- SSL setup
- Remote MongoDB
This is a combination of instructions from multiple articles, but mostly from @jamiewilson's amazing gist tutorial with a few edits to the MUP portion.
- Login to DigitalOcean and create a droplet
- Select Ubuntu 16.04 distribution
- Add secret PEM key
ssh [email protected]adduser username- Enter UNIX password and confirm
gpasswd -a username sudosudo visudo- Replace
%sudo ALL=(ALL) ALLwith%sudo ALL=(ALL) NOPASSWD:ALL su - usernamemkdir .sshchmod 700 .sshnano .ssh/authorized_keys- Copy your local dev SSH key with
cat ~/.ssh/id_rsa.pub | pbcopy - Save edit
- Restrict permissions with
chmod 600 .ssh/authorized_keys - Configure ssh config with
nano /etc/ssh/sshd_config - Change
PermitRootLoginto:PermitRootLogin no exit- Test user connection with
ssh [email protected]
- Add the following domain registrar
- ns1.digitalocean.com
- ns2.digitalocean.com
- ns3.digitalocean.com
- Log back in to DigitalOcean, go to Networking, and click on Domains
- Add a domain and select your DigitalOcean droplet in dropdown
- Add 2 A Records:
- @ / xxx.xxx.xx.xxx
- www / xxx.xxx.xx.xxx
- Add swap space (follow these instructions exactly)
-
Log back in to Droplet server
-
sudo apt-get update -
Install NGINX:
sudo apt-get install nginx -
sudo nano /etc/nginx/sites-available/default -
Add the following and save:
# redirect www to non-www server { listen 80; # to redirect all subdomains use *.yourdomain.com instead of www.yourdomain.com server_name www.yourdomain.com; return 301 $scheme://yourdomain.com$request_uri; } -
sudo nano /etc/nginx/sites-available/yourappname.com.conf -
Add the following and save:
server { listen 80; server_name YOURDOMAIN.com; access_log /var/log/nginx/app.dev.access.log; error_log /var/log/nginx/app.dev.error.log; location / { proxy_pass http://XXX.XXX.XX.XXX:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header X-Forwarded-For $remote_addr; } } -
Link the config file to
sites-enabled:sudo ln -s /etc/nginx/sites-available/yourappname.com.conf /etc/nginx/sites-enabled/yourappname.com.conf -
Hide NGINX number:
sudo nano /etc/nginx/nginx.conf -
Uncomment
server_tokens off; -
Restart NGINX:
sudo service nginx restart -
Test redirect:
curl -I http://www.yourdomain.com
Follow these steps exactly if your app is not ready for public viewing and you want username/password login. Step 3 edits should occur in the /etc/nginx/sites-available/yourapp.com.conf file from Step 7 under NGINX Setup.
npm install -g mupmkdir ~/mup-your-project-name(outside/separate from your actual project repo directory!!!)cd ~/mup-your-project-namemup init- Copy your project's
settings.jsoninto MUPsettings.json - Make following edit to your
mup.jsfilemodule.exports = { servers: { one: { host: 'yourdomain.com', username: 'your_droplet_username' // pem: '~/.ssh/id_rsa' // password: // or leave blank for authenticate from ssh-agent } }, meteor: { name: 'yourappnamewithoutspaces', path: '/local/path/to/your/app/repo', servers: { one: {} }, buildOptions: { serverOnly: true, }, env: { ROOT_URL: 'http://yourdomain.com', MONGO_URL: 'mongodb://localhost/meteor', PORT: 3000 }, docker: { image: 'abernix/meteord:base' // <- THIS IS IMPORTANT }, deployCheckWaitTime: 60 }, mongo: { oplog: true, port: 27017, servers: { one: {}, }, }, }; mup setupmup deploy