在GAE项目中的灵活环境模块之间共享代码 [英] Sharing code between flexible environment modules in a GAE project

查看:75
本文介绍了在GAE项目中的灵活环境模块之间共享代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   -  my-project / $ b我的GAE(flex)项目构建为一系列服务:

$ b - services /
- service_1 /
- service_1.yaml
- service_2 /
- service_2.yaml

我现在想分享一些服务之间的代码。理想情况下,我希望有一个 my-project / lib / ,并将其链接到服务:

  • my-project / services / service_1 / lib - > ../../ lib

  • my-project / services / service_2 / lib - > ../../ lib



  • gcloud app deploy (我从一个服务目录运行,其中 yaml 文件)忽略了符号链接(我检查了 tgz code>文件在上传之前获得了部署的GAE, lib / 不存在)。

    那么,有什么办法可以共享 lib / 代码(除了把它拉进它自己的库并用 pip 可能不适用于 Flex的环境,这是基于码头的。此怀疑基于自定义运行时故障排除


    发行


    • 不包括在我的应用程序中。



    解决方案


    • 当您的源代码树或您的打包系统添加到基本映像时,Docker不会遵循符号链接,因此您的
      源代码树中符号链接引用的应用程序目录
      之外的任何源文件都不会被复制到您的应用程序中。 google.com/appengine/docs/flexible/python/using-python-libraries#declaring_and_managing_dependenciesrel =nofollow noreferrer> flex环境中的依赖关系应该基于要求.txt 存档我们编辑在部署时建立dockerfile,而不是在库中由 pip 将它们安装到 lib dir中标准环境方式


      I'm structuring my GAE (flex) project as a number of services:

      - my-project/
        - services/
          - service_1/
            - service_1.yaml
          - service_2/
            - service_2.yaml
      

      I would now like to share some code between the services. Ideally, I'd like to have a my-project/lib/ and symlink this to the services:

      • my-project/services/service_1/lib -> ../../lib
      • my-project/services/service_2/lib -> ../../lib

      But gcloud app deploy (which I'm running from a service directory, where the yaml file is) ignores the symlink (I checked the tgz file before it got uploaded got GAE for deployment and lib/ isn't there).

      So, is there any way to share the lib/ code (apart from pulling it into it's own library and installing with pip)?

      解决方案

      The method of sharing code across services using symlinks might not be applicable to the flex environment, which is docker-based. This suspicion is based on the last table row from Troubleshooting Custom Runtimes:

      Issue

      • Some files are not included in my application.

      Solutions

      • Docker does not follow symlinks when added by your source tree or your packaging system to the base image, so any source files outside of your applications directory that are referenced by symlinks in your source tree will not be copied into your application.

      Also - dependencies in the flex environment are supposed to be based on a requirements.txt file used to build the dockerfile at deployment time, not on vendoring in libraries by pip installing them into the lib dir which is the standard environment way.

      这篇关于在GAE项目中的灵活环境模块之间共享代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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