Skip to content

thiagoricieri/5min-speed-run-deploy

Repository files navigation

5min Speed Run Deploy

This is a simple setup and deploy scripts to run a server with Nginx, Node and SSL enabled.

Must-Haves

  1. Have your code in a GitHub repository
  2. Have a server running somewhere (I use Digital Ocean)
  3. Have a domain with A record pointing to your server IP

Getting Started

  1. Copy the script to your box using:
scp box/speed_run_deploy.sh root@server_ip:~/speed_run_deploy.sh
  1. Log into your server
ssh root@server_ip

Obs: Assuming you're logging in as root, the script will create a deployer user.

  1. Run the script and follow the instructions!
bash speed_run_deploy.sh

It will install Nginx, PM2, Node.js, setup SSL and Firewall for you.

After Setup...

  1. Exit the box
  2. (From your machine) Copy the public key (it was created in ~/.ssh/deployer.pub in your machine):
cat ~/.ssh/deployer.pub | pbcopy
  1. Go to https://github.com/settings/keys
  2. Click 'Add new SSH' Key and paste the contents in public key field
  3. Copy the private key contents (it was created in ~/.ssh/deployer in your machine):
cat ~/.ssh/deployer | pbcopy
  1. Push your code to Github

  2. Copy the repository URL

  3. Go to https://github.com/<YOUR GITHUB USER>/<YOUR REPO NAME>/settings/secrets/actions

  4. Create secret SSH_PRIVATE_KEY and paste the private key contents

  5. Create secret: SERVER_IP as

  6. Create secret: SERVER_USER as

  7. SSH into your server using the deployer user:

ssh -i ~/.ssh/deployer deployer@<YOUR SERVER IP>
  1. Clone your repository into /var/www/<DOMAIN NAME>
git clone https://github.com/<YOUR GITHUB USER>/<YOUR REPO NAME>.git /var/www/<DOMAIN NAME>

Done! Every merge to main branch will be deployed.

Try it out!

  1. Commit something to the main branch (or the one you selected in setup)
  2. The action will run automatically, wait until it finishes
  3. Access your domain and there you have it!

Boilerplate

Use the template for a Next.js application...

This is a Next.js project bootstrapped with create-next-app. You may use the boilerplate as is, it works!

...or use it for another stack!

You just need the following files if you want just the deploy script:

.github/actions/deploy.yaml
.github/workflows/deploy-prod.yaml
box/speed_run_deploy.sh

You will also need to edit speed_run_deploy.sh because it creates a deploy.sh script that you may want to edit.

Cheers,

Thiago V Ricieri

About

It only takes 5min to deploy a vps server!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published