-
This article assumes you're already connected to a VM that has rbenv, postgres, and caddy installed, and an
/apps
folder created. -
Steps
-
Point the domain/subdomain that you want to use, to the ip address of the server (create an A record).
-
Connect to that newly created domain using the VS Code Remote SSH extension (assuming you have an authorised ssh key or password).
-
ssh root@staging.mydomain.com
-
-
Pull your codebase down from Github into the apps folder. When prompted for credentials, don't enter your normal password. Instead, create a personal token here and enter it when prompted for a password.
-
cd /apps git clone https://github.com/my_repo app_name
-
-
Copy over your environment variables
-
Run
bundle install
,rake db:create
andrake db:migrate
as usual -
Add passenger to your Gemfile
-
gem 'passenger' bundle install
-
-
Start a new daemonized server with passenger on port 1111 (use a different port if this VM already has other apps that are using that port)
-
bundle exec passenger start --daemonize -p 1111
-
-
Configure caddy to forward your newly running app (on port 1111) to your subdomain (from step 1)
-
Open up
/etc/caddy/Caddyfile
-
staging.mydomain.com { reverse_proxy localhost:1111 }
-
Restart caddy
-
service caddy restart
-
-
-