简体   繁体   中英

How can I deploy to Google App Engine an app that depends on a yarn workspaces without publishing the packages to a npm registry?

I am currently migrating our monorepo to yarn workspaces. It contains multiple packages and services. Services depends on packages in their respective package.json . I would like to deploy my services to Google App Engine without having to publish the packages to a private npm registry.

I managed to deploy a single service by using a custom runtime and by moving the app.yaml and the Dockerfile to the root of the monorepo in order to have access to the packages and the service in the build context. The issue is that I have multiple services and I cannot have all the dockerfiles at the root of the monorepo, as they have to be named Dockerfile and that I cannot change the build context.

I see 2 naive solutions:

The first would be to move the app.yaml and Dockerfile of the corresponding service to the root of the monorepo before deploying. But this looks quite dirty and would make the CI code very complicated.

The second would be to have a single Dockerfile and service1.yaml , service2.yaml etc. at the root of the monorepo and to pass variables to the Dockerfile. The problem is that I don't see any way in App Engine documentation to pass variables to the Dockerfile of a custom runtime.

My dream solution would be to be able to keep each Dockerfile and app.yaml in the directory of their respective services and to be able to set the build context through the gcloud CLI (like we can do in docker-compose ). Example:

project
├── package.json
├── packages
│   ├── package1
│   │   ├── package.json
│   │   └── src
│   ├── package2
│   │   ├── package.json
│   │   └── src
│   └── package3
│       ├── package.json
│       └── src
├── services
│   ├── service1
│   │   ├── app.yaml
│   │   ├── Dockerfile
│   │   ├── package.json
│   │   └── src
│   └── service2
│       ├── app.yaml
│       ├── Dockerfile
│       ├── package.json
│       └── src
└── yarn.lock

and run something like: gcloud app deploy services/service1/app.yaml --build-context=.

But I don't see any way of doing this in the documentation.

Do you know how I can get closer to my "dream solution"?

Adding possible option suggested in comments to give more visibility.

One possibility would be keeping the docker-compose workflow that you were using and integrate it with your App Engine deploys.

As you were already building your docker images with docker-compose in order to specify the build context, you can push the result of the build operations to Google's Container Registry so the images can be later used to deploy App Engine by using the --image-url flag .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM