Deployment
The front end is a static SPA deployed to S3 and served through CloudFront using the Serverless Framework and serverless-finch.
Stages
| Stage | URL | S3 bucket | Branch / trigger |
|---|---|---|---|
dev |
play.dev.abstractplay.com | abstract-play-dev |
develop push |
prod |
play.abstractplay.com | abstract-play-prod |
Version tags (v*) |
Defined in serverless.yml.
Build commands
| Command | Effect |
|---|---|
npm run build-dev |
Production build with REACT_APP_REAL_MODE=development |
npm run build-prod |
Production build with REACT_APP_REAL_MODE=production; generates sitemap |
npm run deploy |
Upload build/ to dev S3 bucket |
npm run deploy-prod |
Upload build/ to prod S3 bucket (--stage prod) |
npm run full-dev |
build-dev + CloudFront invalidation + deploy |
npm run full-prod |
build-prod + CloudFront invalidation + deploy |
AWS setup
- Install AWS CLI.
- Configure profiles
AbstractPlayDevandAbstractPlayProdin~/.aws/credentials. - Install Serverless globally:
npm install -g serverless. - First-time stack setup:
serverless deploy(dev) andserverless --stage prod deploy(prod) to create S3 buckets and CloudFront distributions. - Copy CloudFront distribution IDs into the
invalidateandinvalidate-prodscripts inpackage.json.
CI/CD
GitHub Actions workflows:
.github/workflows/deploy-dev.js.yml— push todevelop.github/workflows/deploy-prod.js.yml— version tags
CI steps:
- Install Serverless and npm dependencies (with GitHub Packages auth).
- Install
@abstractplay/renderer@developmentand@abstractplay/gameslib@development. npm run build-devorbuild-prod.serverless client deploy.- CloudFront cache invalidation.
Cache headers
serverless.yml sets object headers on upload:
- Fingerprinted assets (
static/**,flags/**):max-age=31536000, immutable index.html,error.html:no-cache, no-store, must-revalidate- Other objects:
max-age=3600
SPA routing
The serverless-single-page-app-plugin rewrites unknown paths to index.html so client-side routing works on refresh.
Dependencies on other repos
CI installs @development tags of gameslib and renderer on each deploy. Gameslib CI can also trigger a front rebuild via repository_dispatch when rules engine changes land.