Monorepo with multiple node server scripts as siblings

Hey everyone,

We have an app that has multiple “servers” that run side by side. We would like each script to be its own fly app.

ie.
/src/server.ts
/src/graphql-server.ts

So we are looking for the best way to add additional fly.toml and Dockerfile to the same directory, figured someone has already come across this and will have an elegant solution.

Here is our current Dockerfile:

FROM node:current-alpine

WORKDIR /app

COPY package.json .

COPY dist ./dist

RUN yarn install

COPY prisma ./prisma

RUN yarn prisma generate

COPY . .

CMD ["node", "dist/server.js"]

Thanks in advance!

You can pass in the config file and Dockerfile when building, so each app can be in it’s own directory while still sharing common docker context. For example:

flyctl deploy . --config ./prisma/fly.toml --dockerfile ./prisma/Dockerfile

or

flyctl deploy . --config ./fly.prisma.toml --dockerfile ./prisma.Dockerfile
3 Likes

Thanks @michael - Almost too simple!

Much appreciated!

1 Like