如何在Cloud Foundry中将自定义C共享库与Java应用程序捆绑在一起? [英] How do I bundle a Custom C Shared Library with Java Application in Cloud Foundry?
问题描述
我以前一直在Cloud Foundry中成功部署Java应用程序。但是,现在开发人员已经添加了一个用C编译的共享库。我已经在 .zip
中添加了 .so
。文件(我正在使用通用打包程序,并通过zip文件部署到Cloud Foundry),并确保 .so
是可执行的。但是,当我部署时遇到错误:
I have previously been deploying a java application successfully in Cloud Foundry. However, now the developers have added a shared library compiled from C. I have added the .so
to the .zip
file (I'm using universal packager and deploying to Cloud Foundry by zip file) and ensured the .so
is executable. However, when I deploy I get an error:
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。但是,我现在被代码困住了:
https://github.com/ONSdigital/java-buildpack/blob/master/bin/compile#L28
So my understanding is that I need to created a Custom Buildpack from the Java Buildpack. However, I am getting stuck with the code at this point: 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。
From what I can gather I only need to modify the compile
stage. What do I need to do to copy over the .so
and have the Buildpack run successfully.
推荐答案
请查看以下 https ://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile
您需要的运行前挂钩。我无法提供更多详细信息,因为您没有提供足够的信息(项目结构,根目录中是否包含.profile等)。
Pre-Runtime Hooks that's you need. I can't give you more details because you haven't provided enough information (project structure, do you have .profile in you root and etc.).
如果需要添加共享库尝试使用 attr_reader:additional_libraries
https://github.com/cloudfoundry/java-buildpack/blob/master/docs/extending-droplet.md
If you need to add shared libs try to use attr_reader :additional_libraries
https://github.com/cloudfoundry/java-buildpack/blob/master/docs/extending-droplet.md
这篇关于如何在Cloud Foundry中将自定义C共享库与Java应用程序捆绑在一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!