This README explains how to generate a static version of the NextJS site.
We host Teammate Hunt 2020 and Teammate Hunt 2021 on Vercel's free tier. Mystery Hunt 2023 timed out during deploys, but this process was used to generate the static files
teammate has used these with success, though YMMV.
- Grab a dump of the prod database. This can be done on the prod machine with
docker-compose exec -T -u postgres db pg_dump postgres > ~/prod-{date}.dump
. - Dump the prod database into the local database.
./teardown # ensure the local container is stopped docker volume rm mh-20xx_pgdata # nuke the old database (replace mh-20xx) docker-compose -f docker-compose.yml -f deploy/docker-compose.staging.localhost.yml up -d db # start just postgres docker-compose exec -T -u postgres db postgres < prod-{date}.dump # load the prod database
- Ensure media assets are synced.
docker run --rm -it -v mh-20xx_srv:/srv -w /srv alpine rm -rf media # clear old media assets (replace mh-20xx) ./scripts/sync_media --full mh-20xx_srv # run the script to sync assets from Drive (replace mh-20xx)
- Build and start the posthunt version of the site with
./scripts/initialize_staging_localhost --posthunt
. - (optional) Apply any fixture database changes between the prod site and the archive. For example, this might include:
- Removing any answers/data from the public access team.
- Updating puzzle positions.
docker-compose exec -T tph /app/server/manage.py puzzle_positions --fixtures-dir fixtures
- Any database changes needed for specific puzzles on the static site.
- Fix all the FIXMEs and then run the export script
./posthunt/export_site.sh
. We suggest your read through the comments of the script to understand what steps might need to be adapted for your hunt. - If deploying to Vercel, also copy over the
vercel.json
file. (This is currently commented out in theexport_site.sh
.) This tells Vercel to use clean URLs (aka hits tofoo.html
will redirect tofoo
but will read fromfoo.html
).
Now posthunt/exported_static_site
has the entire static site.
[this takes care to ensure that old https://teammatehunt.com/* links redirect across HTTPS]
Vercel:
- add the repository (from the teammatehunt-public user) to a new project
- create 20xx.teammatehunt.com as a production domain
- add the teammatehunt.com domain to the 20xx.teammatehunt.com project and have it do a 301 redirect
Namecheap:
- make 20xx.teammatehunt.com use a CNAME to point to the vercel server
- change the teammatehunt.com (
@
) A record address to vercel's IP (76.76.21.21)