Deploying the app
September 21, 2020 · View on GitHub
↩ Back to README
If you decide to deploy to Heroku:
- Heroku Command Line Interface
- If you have HTTPS enabled (requires a paid dyno), be sure to enable
config.force_ssl = trueon line 47 ofconfig/environments/production.rb
If you decide to use Docker:
Note: These instructions assume you are working with shell access to a system with Docker and docker-compose available (such as a Digital Ocean Docker image).
Note: These instructions assume you already have a domain name registered and pointed it at the IP address of your server.
-
You'll need to get the code on the server. The recommended way to do this is with a GitHub Deploy Key. Deploy Keys are just SSH keys that are tied to a project, instead of being tied to a user, which means that they can persist independently of the project's membership. You can use GitHub's guide on generating SSH keys to generate your deploy key.
-
After you've generated your deploy key and added it to your project, clone the project.
-
Create a Caddyfile. It can live anywhere (Mutual Aid Tompkins has ours at
~/.config/Caddyfile), and it should look like this, replacingyour.domain.namewith your organization's desired domain name:your.domain.name { header { Strict-Transport-Security "max-age=31536000; includeSubdomains; preload" } root * /config/public # Serve static files (like assets and packs) with the file_server @static_files { file } file_server @static_files # Anything that's not a static file, proxy to puma/rails @backend { not file } reverse_proxy @backend http://app:3000 } -
Navigate to the
docker/productiondirectory within your clone of the repo. You should see a file nameddocker-compose.yml. -
Run
docker-compose run app '/usr/local/bin/rake' secret \ | echo "SECRET_KEY_BASE=$(tail -1 -)" > .envThis will generate a secret token and add it to a file named
.env, which will be available whendocker-composestarts. -
Generate (using a password manager) a password for the Postgres database, and append it to the
.envfile. Your.envfile should look something like:SECRET_KEY_BASE=<A fairly long string of numbers> POSTGRES_PASSWORD=<your postgres password> -
Start the server, database, and reverse proxy by running
docker-compose --build -d -
Initialize the database with
docker-compose run \ -e SYSTEM_EMAIL="theemailyouwanttouse@example.com" \ -e SYSTEM_PASSWORD="ThePasswordYouWantToUse" \ app rails db:prepare db:seedThis will setup the database and create a default admin user with the email and password as specified by the
SYSTEM_EMAILandSYSTEM_PASSWORDenvironment variables you passed todocker-composewith the-eoption. If you don't want to create the default user, you can just rundocker-compose run app db:prepareand create the account using the sign up option on the website. Only run this command the first time you set up your instance
You should be good to go! Visit your domain name to get started.
Make sure to run rake db:seed
↩ Back to README