packages
- api (this is what i want to deploy)
- schema
- web
I’m using yarn2+ workspaces api is express based ts project
I want to deploy only packages/api but the problem is, i cant just build on fly.io (/packages/api > fly deploy), because api requires packages/schema so build process fails with error like cant find packages/schema during yarn install on server.
how can i approach this without copying the whole monorepo to fly io?
I thought maybe i can somehow pre-build my api locally and then upload to fly io, but i don’t understand how to do this… how do i pack or add all dependencies to the build?
currently i build using "build": "tsc -b" but .dist do not contain dependencies so node dist/index.js fails on server because it cant find dependencies
However i wonder if there any automatic way of doing this. I mean to bundle or prepare to deploy the package, based on its dependencies. Idk, maybe turborepo or nx can simplify such cases
I realized there is another issue with this: I need to have multiple fly.io projects inside my monorepo. E.g. api and web are 2 separate fly.io deployments. So i need separate dockerfile/ fly.toml per each of package.
If i just contenerize the whole repo and ignore /web, i will get only one fly project per my whole monorepo
While running two separate servers (on different ports) is common during development, for deployment there typically is only one server; the client portions are build into static assets that are served by a web server that serves static assets (html, css, js, images) as well as dynamically handing api requests. The details vary based on framework. Here’s Next.js’s docs:
I didnt get it, how it relates to my problem i want to kinda “pick” the package out of my monorepo and deploy it to fly.io. Currently the problem only with local dependencies: i do not know how to provide dependencies(@myrepo/schema) of my package(@myrepo/api) to fly.io without copying the whole monorepo to fly and then yarn install in specific package(@myrepo/api)
Usually monorepo libraries have a way to bundle your app and its relevant local dependencies into a docker container. Look up the docs, if it doesn’t then change to one that does.