If you find issues or can improve this guide, please create a pull request at:
2. Setup the server
We’ll be running our server under the user called slugex
. So, we first need
to create that user.
1 | ## commands to be executed on our server |
3. Install the git-deploy rubygem on our local computer
We’ll be using the git-deploy rubygem to do deploys. This allows deploys similar to Heroku. You just need to push to your production git repository to start a deployment.
1 | ## commands to be executed on our local computer |
4. Setup distillery in our phoenix app (on local computer)
We’ll be using distillery to manage our releases.
Add the distillery dependency to our mix.exs
1 | defp deps do |
Init the distillery config
1
2
3
4# get dependencies
mix deps.get
# init distillery
mix release.init
Change rel/config.ex
to look like below
1 | ... |
5. Setup git deploy (local computer)
Let us setup the remote and the deploy hooks
1 | ## commands to be executed on our local computer |
TODO: release this as a book
6. Setup postgresql access
1 | ## commands to be executed on the server as the slugex user |
6. Setup the prod.secret.exs
Copy the config/prod.secret.exs file from your local computer to /opt/www/slugex/config/prod.secret.exs
1 | ## on local computer from our phoenix app directory |
create a new secret on your local computer using mix phoenix.gen.secret
and
paste it in the server’s config/prod.secret.exs secret
It should look something like below:
1 | # on the server |
6. Tweak the deploy scripts
7. One time setup on the server
1 | ## commands to be executed on server as slugex |
Logger
Exception notifications
Setup systemd
6. One time setup on server (on server as slugex user)
1 | ## commands to be run on the server as the slugex user |
6. Nginx configuration
7. Letsencrypt setup and configuration
9. TODO: Configuration using conform
10. TODO: database backups to S3
10. TODO: uptime monitoring of websites using uptime monitor
10. TODO: email via SES
10. TODO: db seeds
10. TODO: nginx caching basics, static assets large expirations
10. TODO: remote console for debugging
sudo letsencrypt certonly –webroot -w /opt/www/webmonitor/public/ -d webmonitorhq.com –webroot -w /opt/www/webmonitor/public/ -d www.webmonitorhq.com
11. Check SSL certificate: https://www.sslshopper.com/ssl-checker.html
Common mistakes/errors
- SSH errors
Improvements
- Automate all of these using a hex package?
- Remove dependencies on
git-deploy
if possible - Hot upgrades