Skip to content

Production Installation

camdenmoors edited this page Aug 13, 2020 · 11 revisions

Note: The most tested way of deploying the ctf-scoreboard is using Heroku, or if you want to use your own server then using https://github.com/dokku/dokku. Don't deploy this in production without a proper and secure reverse proxy.

Docker

These steps are for production deployments using docker-compose.

Prerequisites

  • If you have not already, follow the steps to install docker-compose.

Installation

  • Generate credentials: ./setup-docker-secrets.sh
  • Run scoreboard database setup: sudo docker-compose run web bash ./setup.sh --setupdb --production
  • Edit your nginx config and set your server's hostname in default.conf
  • Start the container: sudo docker-compose up -d

Dokku

These steps are for production deployments using Dokku.

Prerequisites

  • If you have not already installed Dokku, follow the steps to install Dokku.
  • Ensure you have the Dokku Postgres plugin installed
  • Ensure you either have the LetsEncrypt plugin installed or manual management of your SSL certificates. The app will not work without some sort of SSL certificate generated.

Installation

  • Create a new application on your dokku server: dokku apps:create ctf-scoreboard
  • Create a new postgres database on your dokku server: dokku postgres:create scoreboard-db
  • Link the database to the application on your dokku server: dokku postgres:link scoreboard-db ctf-scoreboard
  • (Optional) Setup the proxy for your application: dokku --app ctf-scoreboard config:set HTTP_PROXY=http://<proxy-server>, dokku --app ctf-scoreboard config:set HTTPS_PROXY=http://<proxy-server>
  • Add your dokku server as a git remote on your local machine for the application
    • Clone the scoreboard locally using the clone button on the main page.
    • Add the remote by running git remote add ctf-dokku dokku@<address>:ctf-scoreboard
  • Push the code to dokku in order to create an initial copy of the project on your server, from within your local git copy: git push ctf-dokku master.
    • Note: If you would like to deploy a branch other than master to dokku you can run git push ctf-dokku otherbranch:master.
  • The application is setup to automatically run migrations during a code push, however this causes problems during the initial deploy. In order to get a clean initial deployment, run the following commands on your Dokku
    • Set the rails environment dokku --app ctf-scoreboard run rails db:environment:set RAILS_ENV=production
    • Drop and recreate the database by running dokku --app ctf-scoreboard run rake db:drop db:create db:schema:load DISABLE_DATABASE_ENVIRONMENT_CHECK=1
  • Push the code to dokku again using either git push ctf-dokku master or git push ctf-dokku otherbranch:master. This time the build will pass and your application will be deployed.
  • Add a domain to access your application by running dokku --app ctf-scoreboard domains:add <yourdomain>.
  • Setup your certificates by either using LetsEncrypt or dokku certs:generate ctf-scoreboard <yourdomain>.
  • Your app should now be accessible in the browser. Browse to in order to complete setup of your game and challenges.

Generic Deployment Instructions

  • Install ruby (using a ruby version manager like rvm is recommended).
  • In your terminal run gem install bundler
  • Install postgres to your system (and create a role with your system username sudo -u postgres -i then createuser --interactive).
  • Setup Recaptcha. This can be done by getting a site key from here and then setting the RECAPTCHA_SITE_KEY and RECAPTCHA_SECRET_KEY environment variables for the application. The steps for this will vary based on your hosting platform.
  • Run bundle install to install dependencies
  • Run bundle exec rake db:create to create the database
  • Run bundle exec rake db:schema:load to load the database schema
  • Run bundle exec rake db:create_admin to launch an interactive session to create an administrator
  • Run bundle exec rails s -e production to launch the server in production mode
  • Open the webpage shown in your terminal from the last command in your browser.
  • Login to the registration app http://localhost:3000 as the admin user you created.
  • Access the administration panel at http://localhost:3000/admin to configure the application.

Clone this wiki locally