如何从具有依赖关系的大型monorepo到一个与Google app引擎相同的repo中的程序包部署一个应用程序? [英] How to deploy one app from a large monorepo with dependencies to packages in the same repo to google app engine?

查看:80
本文介绍了如何从具有依赖关系的大型monorepo到一个与Google app引擎相同的repo中的程序包部署一个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大型的node.js monorepo,其中包含多个应用程序和程序包以及相互依赖性.所有这些都通过纱线工作区和一些lerna进行管理.一切对我来说都很好,但是我在尝试将此Monorepo中的应用程序之一部署到Google App Engine时遇到了麻烦.

I have a large node.js monorepo with several applications and packages and inter dependencies. It is all managed with yarn workspaces and a little bit of lerna. Everything works great for me, however I am having trouble trying to deploy one of the applications in this monorepo to google app engine.

主要问题是,应用引擎希望安装仅位于本地且不在npm上的软件包,并且会引发错误.

The main issue is that the app engine wants to install packages that are located only locally and are not on npm, and it throws an error.

我已经搜索了Google Cloud文档,但没有找到任何可用于指定自定义节点程序包的内容或类似内容.

I've scoured the google cloud documentations but did not manage to find anything that I could use to specify custom node packages or anything similar.

有没有一种方法可以在不将本地软件包发布到npm的情况下进行这种部署?

Is there a way to make such a deployment without publishing the local packages to npm?

我要部署的应用程序的基本结构如下:

The basic structure of the app I want to deploy looks like this:

-root
    -packages
        -packageA
            -package.json
    -apps
        -deployable-app
            -package.json <-contains dependency: "packageA": "0.0.1"
            -app.yaml

推荐答案

通过仅将 deployable-app 以及与取决于(在您的情况下为 packageA ).

安装时,yarn将完成所有工作以链接它们之间.

When installing, yarn will do all the work to link between them.

注意:

  • 确定性安装-建议在monorepos中强制执行确定性安装,因为nodejs packag emanager(pnpm,yarn,npm)不会读取应用程序依赖项的锁定文件,因此在运行install时,并且 packageA 位于公共/私有npm-registry中,程序包管理器将根据需要安装 packageA 依赖项.但是,您的monorepo中有一个 yarn.lock 文件,该文件描述了应该正确安装的版本以及哪个版本.

  • Deterministic installation - It is recommended to do so in monorepos to force deterministic install because nodejs packag emanagers (pnpm, yarn, npm) does not read the lock files of the dependencies of your app so when you run install, and packageA is located in public/private npm-registry, the package manager will install packageA dependencies as he wants. But you have a yarn.lock file in your monorepo that described what exectly should be installed and in which version.

较小的docker映像,更好的缓存-仅从Monorepo复制您的 deployable-app 需要的本地软件包,并创建一个脚本,该脚本从所有package.jsons中删除所有devDependenciesmonorepo(在dockerfile内部)生产中不需要它们.缩小图片.

Small docker image, better caching - Copy only the local packages from your monorepo that your deployable-app needs and create a script that removed all devDependencies from all the package.jsons in the monorepo (inside the dockerfile). they are not needed in production. make your image small.

这篇关于如何从具有依赖关系的大型monorepo到一个与Google app引擎相同的repo中的程序包部署一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆