Fly.io Simple Monorepo Demo
This is a simple monorepo demo to showcase how to deploy multiple apps to fly.io using one Dockerfile.
In the monorepo you'll find 2 apps and 4 packages
api-gateway
: an express.js server that proxies 2 enpoints.web-server
: another express.js app that just returns the current path that a user enters
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
Install Dependencies
npm install
npm run dev
npm run build
Install and setup flyctl
$ fly apps create api-gateway
$ fly apps create web-server
Check that the app variable name in the fly.[app-name].toml
file is the same name you used to create the app in the previous step
# fly.gateway.toml
app = "monorepo-demo-web" <- this line
primary_region = "lax"
...
Also check that the PROJECT
arg in the fly.[app-name].toml
file (located in the [build.args]
section) is the same name as your app folder.
#fly.gateway.toml
...
[build.args]
PROJECT="api-gateway" # This should match the app name folder
...
Deploy to fly.io
$ fly deploy --config fly.gateway.toml
$ fly deploy --config fly.web.toml
You also use the included deploy.sh
to deploy all apps at once
$ chmod +x deploy.sh
$ ./deploy.sh