如何在 Cloud Foundry 中将自定义 C 共享库与 Java 应用程序捆绑在一起?

How do I bundle a Custom C Shared Library with Java Application in Cloud Foundry?

我之前已经在 Cloud Foundry 中成功部署了一个 java 应用程序。然而,现在开发人员已经添加了一个从 C 编译的共享库。我已经将 .so 添加到 .zip 文件(我正在使用通用打包程序并通过 zip 文件部署到 Cloud Foundry)并确保.so 可执行。但是,当我部署时出现错误:

2016-12-23T14:39:01.013+00:00 [STG/0] [OUT] -----> Java Buildpack Version: eba4df6 | git://github.com/cloudfoundry/java-buildpack.git#eba4df6
2016-12-23T14:39:01.017+00:00 [STG/0] [ERR] [Buildpack] ERROR Compile failed with exception #<RuntimeError: No container can run this application. Please ensure that you’ve pushed a valid JVM artifact or artifacts using the -p command line argument or path manifest entry. Information about valid JVM artifacts can be found at https://github.com/cloudfoundry/java-buildpack#additional-documentation.
2016-12-23T14:39:01.017+00:00 [STG/0] [ERR] No container can run this application. Please ensure that you’ve pushed a valid JVM artifact or artifacts using the -p command line argument or path manifest entry. Information about valid JVM artifacts can be found at https://github.com/cloudfoundry/java-buildpack#additional-documentation.
2016-12-23T14:39:01.022+00:00 [STG/0] [ERR] Failed to compile droplet
2016-12-23T14:39:01.024+00:00 [STG/0] [OUT] Exit status 223

所以我的理解是我需要从 Java Buildpack 创建一个 Custom Buildpack。但是,此时我被代码困住了: https://github.com/ONSdigital/java-buildpack/blob/master/bin/compile#L28

# Adding crf tagger library
status "Adding crf tagger support"
cp $bp_dir/parsers/src/main/resources/libbackend.so $build_dir/vendor/

# update the PATH
status "Building runtime environment"
mkdir -p $build_dir/.profile.d
echo "export PATH=\"$HOME/bin:$HOME/vendor/:$PATH\";" > $build_dir/.profile.d/crftagger.sh
echo "export LD_LIBRARY_PATH=\"$HOME/vendor/\";" >> $build_dir/.profile.d/crftagger.sh

据我所知,我只需要修改 compile 阶段。我需要做什么才能复制 .so 并成功获得 Buildpack 运行。

请看这个https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile

您需要的运行前挂钩。我不能给你更多的细节,因为你没有提供足够的信息(项目结构,你的 root 中是否有 .profile 等)。

如果您需要添加共享库,请尝试使用 attr_reader :additional_libraries https://github.com/cloudfoundry/java-buildpack/blob/master/docs/extending-droplet.md