Welcome to the Bedlam Theatre Scavenger Hunt scoring website.
Code by Mick Zijdel, styling and specification by Lewis Eggeling
IMPORTANT NOTE: The Rails server is accessible within the Docker container or in development* on port 3000
. However, the server is accessible within the Docker Host/outside of the Docker container on port 2024
.
See the Bedlam Theatre Wiki for EUTC-specific deployment things.
I would strongly advise first deploying it to Docker locally before deploying. You will not be able to access the locally-deployed website once it is up because of SSL certificates, but at least you can check for issues in the deploy process.
The deploy steps (first-time only) are:
- Clone this repository.
- Navigate into the repository.
- Add a
.env
file with the contents below. - Run
sudo docker compose -f docker-compose.yml up -d
a) This will create new containers and start them detached so it will still run when you log out. - Setup your Nginx configuration file using the options below.
a) If you're not using Nginx (or an alternative) as a reverse proxy, everything should just work if you connect to port2024
(you can change this port in thedocker-compose.yml
file, for example to the default http port80
or https port443
). This is untested though. Feel free to let Mick know and he might be able to help, but it's probably easiest if you just run Nginx as a reverse proxy. - That's it! You can check if the containers are running using
sudo docker ps
Tip: If the docker compose
fails because of a bundle issue, you can unfreeze the bundle by adding the line RUN bundle config set frozen false
just before RUN GIT_EXECUTABLE=/usr/bin/git bundle install
in the Dockerfile. This is not best practice because your packages might not match those in development, but sometimes there are minor inconsistencies when developing on Windows and deploying on Linux.
To upgrade:
- Navigate into the repository
- Pull the updates from the repo from source using
git pull
- Run
sudo docker compose down
to stop the current stack/containers. - Run
sudo docker compose -f docker-compose.yml up -d
a) You might need to add the--build rails
or--force-recreate
options when upgrading.
If you run into any issues here, please check the deploy instructions above.
Ensure that the environment variables are specified in Portainer or in an .env
file as follows:
RAILS_MASTER_KEY=<the master key>
DATABASE_NAME=scav_hunt_production
DATABASE_PASSWORD=<Anything you want>
HOST_URL=<host website, like scavhunt.bedlamtheatre.co.uk. Do not include the scheme. You only need to include the port if you need to specify it when connecting to the website in the browser>
In production, this website uses Redis as an ActionCable backend. The main consequences are
- The
action_cable.allowed_request_origins
config needs to be set inproduction.rb
, which is done based on theHOST_URL
env variable. - You need to add a location to your Nginx config file within the server for the scav-hunt website. See the sample Nginx config below.
Add this server to your Nginx config file. You might need to change the domain and SSL certificate locations.
# New server block for scavhunt.bedlamtheatre.co.uk
server { listen 443 ssl; server_name scavhunt.bedlamtheatre.co.uk;
ssl_certificate /opt/nginx/certs/bedlamtheatre.co.uk.pem;
ssl_certificate_key /opt/nginx/certs/bedlamtheatre.co.uk.key;
location / {
proxy_pass http://127.0.0.1:2024;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Need to explicitly define the /cable location (the upgrade part is the essential part) for websockets to work.
location /cable {
proxy_pass http://127.0.0.1:2024;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
docker ps
, for a list of all containers and their IDsdocker logs <container_id> --tail 100
, to view the logsdocker exec <container_id> <command>
, to run an arbitrary command within the containerdocker exec -it <container_id> /bin/bash
, to run an interactive shell in a container (keep in mind Docker containers are very slim and don't even have nano)
- Install Ruby (see gemfile for version)
- Install Node.js/Yarn (most recent probably fine. I used Node 22)
- Install MySQL server
- Create a MySQL database user with the username
scav_hunt
and an empty password who has access to all schemas matching the patternscav\_hunt\_%
, or just all schemas using%
. You can set the access restriction tolocalhost
for extra security. - Clone this repository
- Copy the
master.key
file to your local repository. Ask someone who already has it for a copy. - Run
bundle install
- Run
yarn install
- Run
rails db:setup
- Run
rails s
and check if the website loads atlocalhost:3000
- You might need to run
yarn build
andyarn build:css
if changes you make do not automatically reload.
- Run
rails test:all -d
. You can userails test -h
for more details, for example, how to run a specific test file only. - You can view test coverage by opening
coverage/index.html
using a browser of your choice.