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

时间:2016-12-23 14:50:34

标签: java cloudfoundry buildpack

我以前在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成功运行。

1 个答案:

答案 0 :(得分:2)

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

预运行时挂钩你需要的。我不能给你更多的细节,因为你没有提供足够的信息(项目结构,你在你的根目录中有.profile等)。

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