Trivial is a small web application that mimics Trivial Pursuit's card system. Cards are added with questions and answers, and assigned to a category. When in presentation modes, the cards within a category are shuffled and shown one by one.
The application contains predefined categories, but categories can be added and removed at will. These are system-wide.
The application is divided in sets which contain cards. Each card has a question, a response and a category.
Use the bin/setup script or run the following steps manually.
Set up the PostgreSQL database:
rails db:setup
Initialize database seeds:
rails database:seed # Production and development seeds
rails database:seed:production # Production seeds
rails database:seed:development # Development seeds
Run database migrations:
rails db:migrate
Use the bin/update script to update your development environment dependencies.
Seed the test database before running the test suite:
rails database:seed:production RAILS_ENV=test
Run the test suite:
rspec
Github secrets for continuous deployment:
DEPLOY_SSH_HOSTDEPLOY_SSH_USERDEPLOY_SSH_KEYREGISTRY_TOKEN(needed for Github Container Registry)SMTP_USERNAMESMTP_PASSWORDSMTP_FROMSMTP_TO
Update the changelog and bump the version using the bin/version tool.
Execute bin/version --help to see all parameters.
Create a tag for the version and push it to Github.
A Docker image will automatically be built and pushed to the registry.
bin/version version 1.0.0
git add lib/trivial/version.rb web/package.json
git commit -m "Bump version to v1.0.0"
git tag v1.0.0
git push origin master
git push origin v1.0.0Initial deployment
# SSH into the server
ssh root@myserver.com
# Create a user
useradd -d /data/apps/trivial -G ssh -G docker -m -s /bin/bash trivial
su - trivial
# Create SSH keypair
myserver$ mkdir ~/.ssh/
ssh-keygen -f ~/.ssh/trivial-deployment-key -b 4096 -C "Trivial deployment key"
cp ~/.ssh/trivial-deployment-key.pub ~/.ssh/authorized_keys
# Initialize the database
docker exec -ti thalarion_postgres_1 psql -U postgres -c "CREATE ROLE trivial WITH ENCRYPTED PASSWORD trivial LOGIN;"
docker exec -ti thalarion_postgres_1 psql -U postgres -c "CREATE DATABASE trivial OWNER trivial;"
# Logout, but don't forget to copy over the private key to your local machine
logout
logout
# Copy and edit environment file
cp .env.development ops/.env.production.local
edit ops/.env.production.local
scp -i ~/.ssh/trivial-deployment-key.pub ops/.env.production.local /data/apps/trivial/production.envAdditionally, set DEPLOY_SSH_KEY, DEPLOY_SSH_HOST and DEPLOY_SSH_USER as Github Actions secrets.
Subsequent deployments
Ensure the images have been built and are available in the container registry.
Apply your changes in ops/docker-compose.yml.
Update the production tag to the correct commit and push it to Github
The file will automatically be deployed, and the containers recreated.
nano ops/docker-compose.yml
git add ops/docker-compose.yml
git commit -m "Update images to latest version"
git tag -f production
git push origin master && git push -f origin productionFor initial deployment, copy .env.production, client.key and client.pem manually, and initialize the database.
See LICENSE.md.