I'm new to Google Cloud, and can't seem to figure out how to deploy a Google App Engine service that has a sibling local dependency. I have a project structure like this (my stack is TypeScript, nestJS, React):
-frontend
app.yaml
package.json
-backend
app.yaml
package.json
-common
package.json
dispatch.yaml
The frontend
package deploys static code to the default
service, and the backend
package deploys to an api
service. The common
package contains some code that I want to share between the front and backend. They include it in their package.json
files like this:
dependencies: {
common: "file:../common"
}
This structure works fine locally. The problem is that when I deploy the backend, npm install
fails, because it can't find the common
package. This make sense, since I understand that it's only going to upload the contents of backend
to that service. But what is the right way to achieve this?
I suppose I could just deploy one service that contains all of the code, and have my top-level package.json
delegate npm start
to the backend's package.json
. But that only works because my frontend is fully static, so I only have one package that needs npm start
to get called. It seems like there should be a better way to handle this, because that approach would break down if I had two separate backends that each needed their own npm start
.
I'm guessing I'm thinking about some aspect of this in a fundamentally wrong way, but I need help figuring out what that is.