apt-buildpack 是实验性的,尚未用于生产用途。我想这就是为什么也没有文档的原因。
Creating container
Successfully created container
Downloading app package...
Downloaded app package (862.7K)
Warning: this buildpack can only be run as a supply buildpack, it can not be run alone
Failed to compile droplet: Failed to compile droplet: exit status 1
Destroying container
Exit status 223
Stopping instance abdfc8d0-699e-4834-9f2d-2b8aec218423
Successfully destroyed container
您能否举例说明如何推送
cf-env
示例应用程序并安装例如rtorrent和/或openvpn。是否可以安装 gnome 进行测试?
就使用而言,它非常简单,您只需在应用程序的根目录中包含一个
apt.yml
即可。其中应该包含要安装的软件包列表。
例如:
---
packages:
- ascii
- libxml
- https://example.com/exciting.deb
构建包支持安装包名称、deb 文件、自定义 APT 存储库,甚至 PPA。
请参阅自述文件以获取更多说明。
此消息:
警告:此构建包只能作为供应构建包运行,不能单独运行
告诉您 Apt 构建包仅用于提供二进制文件。它实际上不知道如何运行您的应用程序或任何应用程序。有关供应脚本的更多信息,请查看此处的文档。
使其工作的技巧是您需要使用多构建包支持。可以在此处找到相关说明。这应该适用于大多数应用程序,但有一个简单的示例here。
应用程序暂存并启动后,您可以通过运行
cf ssh apt-test -t -c "/tmp/lifecycle/launcher /home/vcap/app bash ''"
来确认您的软件包已安装。安装的所有内容都应该位于路径上,但如果您想查看安装内容的位置,它将位于 /home/vcap/deps/<buildpack-number>/
下。
应该就是这样了。希望有帮助!
接受的答案是正确的,并提供了文档链接,但在这里我想给出一个使用 Maven 进行 WAR 打包的 Spring Boot Java 应用程序的示例。
manifest.yml
中,buildpacks
部分应如下所示: buildpacks:
- https://github.com/cloudfoundry/apt-buildpack.git
- java_buildpack
请注意
apt-buildpack
:a) 使用 git 存储库,因为它是实验性的 b) 位于构建包列表中的第一个。
manifest.yml
中,应用程序工件的路径如下所示:path: ./target/ROOT.war
因此可以在应用程序构建期间将
apt.yml
添加到 WAR 文件中。对于 apt.yml
位于上一级文件夹中 src
,将构建插件添加到 pom.xml
应该可以工作:
...
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>add-apt.yml</id>
<goals>
<goal>run</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<target>
<copy file="${project.build.directory}/../apt.yml" tofile="${project.build.directory}/ROOT/apt.yml" />
</target>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
其中
ROOT
是未来ROOT.WAR
文件的目录。此命令会将 apt.yml
文件复制到生成 WAR 文件的文件夹中。
apt.yml
可能看起来像这样:---
packages:
- libnss3
- libnspr4
- libatk1.0-0
- libatk-bridge2.0-0
- libcups2
- libxkbcommon0
- libatspi2.0-0
- libxcomposite1
- libxdamage1
- libxrandr2
- libgbm1
- libasound2
在此示例中,它放置在应用程序的存储库根目录中,与
pom.xml
和 manifest.yml
相同。
cf push -f manifest.yml
,您应该看到在 Java 构建包启动之前已经安装了 apt 软件包:Staging app and tracing logs...
Downloading java_buildpack...
Downloaded java_buildpack
Cell ac23eeb2-9362-4216-b862-b0123510ab96 creating container for instance ea262703-b1b1-4298-82ec-df56000956fd
Security group rules were updated
Cell ac23eeb2-9362-4216-b862-b0123510ab96 successfully created container for instance ea262703-b1b1-4298-82ec-df56000956fd
Downloading app package...
Downloading build artifacts cache...
Downloaded build artifacts cache (138B)
Downloaded app package (276.3M)
-----> Download go 1.19
-----> Running go build supply
/tmp/buildpackdownloads/3f6188191ee386ccd86c13b8a9cd4b0d ~
~
-----> Apt Buildpack version 0.3.0
-----> Updating apt cache
-----> Downloading apt packages
Reading package lists...
Building dependency tree...
The following additional packages will be installed:
alsa-topology-conf alsa-ucm-conf at-spi2-core dbus dbus-user-session
dconf-gsettings-backend dconf-service gsettings-desktop-schemas
libasound2-data libatk1.0-data libavahi-client3 libavahi-common-data
libavahi-common3 libdconf1 libpam-systemd libwayland-server0 libxi6 libxtst6
session-migration
Suggested packages:
libasound2-plugins alsa-utils cups-common
The following NEW packages will be installed:
alsa-topology-conf alsa-ucm-conf at-spi2-core dbus dbus-user-session
dconf-gsettings-backend dconf-service gsettings-desktop-schemas libasound2
libasound2-data libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0
libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdconf1
libgbm1 libnspr4 libnss3 libpam-systemd libwayland-server0 libxcomposite1
libxdamage1 libxi6 libxkbcommon0 libxrandr2 libxtst6 session-migration
0 upgraded, 31 newly installed, 0 to remove and 60 not upgraded.
Need to get 3,236 kB of archives.
After this operation, 11.8 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 dbus amd64 1.12.20-2ubuntu4.1 [158 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpam-systemd amd64 249.11-0ubuntu3.9 [203 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 alsa-topology-conf all 1.2.5.1-2 [15.5 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libasound2-data all 1.2.6.1-1ubuntu1 [19.1 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 libasound2 amd64 1.2.6.1-1ubuntu1 [390 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 alsa-ucm-conf all 1.2.6.3-1ubuntu1.7 [41.8 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/main amd64 libxi6 amd64 2:1.8-1build1 [32.6 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy/main amd64 libatspi2.0-0 amd64 2.44.0-3 [80.9 kB]
Get:9 http://archive.ubuntu.com/ubuntu jammy/main amd64 libxtst6 amd64 2:1.2.3-1build4 [13.4 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 dbus-user-session amd64 1.12.20-2ubuntu4.1 [9,442 B]
Get:11 http://archive.ubuntu.com/ubuntu jammy/main amd64 libdconf1 amd64 0.40.0-3 [40.5 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy/main amd64 dconf-service amd64 0.40.0-3 [28.5 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy/main amd64 dconf-gsettings-backend amd64 0.40.0-3 [22.8 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy/main amd64 session-migration amd64 0.3.6 [9,774 B]
Get:15 http://archive.ubuntu.com/ubuntu jammy/main amd64 gsettings-desktop-schemas all 42.0-1ubuntu1 [31.1 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy/main amd64 at-spi2-core amd64 2.44.0-3 [54.4 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy/main amd64 libatk1.0-data all 2.36.0-3build1 [2,824 B]
Get:18 http://archive.ubuntu.com/ubuntu jammy/main amd64 libatk1.0-0 amd64 2.36.0-3build1 [51.9 kB]
Get:19 http://archive.ubuntu.com/ubuntu jammy/main amd64 libatk-bridge2.0-0 amd64 2.38.0-3 [66.6 kB]
Get:20 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libavahi-common-data amd64 0.8-5ubuntu5.1 [23.5 kB]
Get:21 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libavahi-common3 amd64 0.8-5ubuntu5.1 [23.7 kB]
Get:22 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libavahi-client3 amd64 0.8-5ubuntu5.1 [28.0 kB]
Get:23 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libcups2 amd64 2.4.1op1-1ubuntu4.4 [264 kB]
Get:24 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libwayland-server0 amd64 1.20.0-1ubuntu0.1 [34.3 kB]
Get:25 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libgbm1 amd64 23.0.4-0ubuntu1~22.04.1 [33.1 kB]
Get:26 http://archive.ubuntu.com/ubuntu jammy/main amd64 libnspr4 amd64 2:4.32-3build1 [119 kB]
Get:27 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnss3 amd64 2:3.68.2-0ubuntu1.2 [1,280 kB]
Get:28 http://archive.ubuntu.com/ubuntu jammy/main amd64 libxcomposite1 amd64 1:0.4.5-1build2 [7,192 B]
Get:29 http://archive.ubuntu.com/ubuntu jammy/main amd64 libxdamage1 amd64 1:1.1.5-2build2 [7,154 B]
Get:30 http://archive.ubuntu.com/ubuntu jammy/main amd64 libxkbcommon0 amd64 1.4.0-1 [125 kB]
Get:31 http://archive.ubuntu.com/ubuntu jammy/main amd64 libxrandr2 amd64 2:1.5.2-1build1 [20.4 kB]
Fetched 3,236 kB in 1s (2,393 kB/s)
Download complete and in download only mode
-----> Installing apt packages
-----> Java Buildpack v4.59.0 (offline) | https://github.com/cloudfoundry/java-buildpack.git#cb826d45
-----> Downloading Jvmkill Agent 1.17.0_RELEASE from https://java-buildpack.cloudfoundry.org/jvmkill/jammy/x86_64/jvmkill-1.17.0-RELEASE.so (found in cache)
-----> Downloading Sap Machine JRE 11.0.19_0.0.b0 from https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.19/sapmachine-jre-11.0.19_linux-x64_bin.tar.gz (found in cache)
Expanding Sap Machine JRE to .java-buildpack/sap_machine_jre (0.9s)
JVM DNS caching disabled in lieu of BOSH DNS caching
-----> Downloading Open JDK Like Memory Calculator 3.13.0_RELEASE from https://java-buildpack.cloudfoundry.org/memory-calculator/jammy/x86_64/memory-calculator-3.13.0-RELEASE.tar.gz (found in cache)
Loaded Classes: 41780, Threads: 250
-----> Multiple Buildpacks detected
apt contributed to: $LD_LIBRARY_PATH, $PATH
-----> Downloading Client Certificate Mapper 1.11.0_RELEASE from https://java-buildpack.cloudfoundry.org/client-certificate-mapper/client-certificate-mapper-1.11.0-RELEASE.jar (found in cache)
-----> Downloading Container Customizer 2.6.0_RELEASE from https://java-buildpack.cloudfoundry.org/container-customizer/container-customizer-2.6.0-RELEASE.jar (found in cache)
-----> Downloading Container Security Provider 1.20.0_RELEASE from https://java-buildpack.cloudfoundry.org/container-security-provider/container-security-provider-1.20.0-RELEASE.jar (found in cache)
-----> Downloading Tomcat Instance 9.0.75 from https://java-buildpack.cloudfoundry.org/tomcat/tomcat-9.0.75.tar.gz (found in cache)
Expanding Tomcat Instance to .java-buildpack/tomcat (0.1s)
-----> Downloading Tomcat Access Logging Support 3.4.0_RELEASE from https://java-buildpack.cloudfoundry.org/tomcat-access-logging-support/tomcat-access-logging-support-3.4.0-RELEASE.jar (found in cache)
-----> Downloading Tomcat Lifecycle Support 3.4.0_RELEASE from https://java-buildpack.cloudfoundry.org/tomcat-lifecycle-support/tomcat-lifecycle-support-3.4.0-RELEASE.jar (found in cache)
-----> Downloading Tomcat Logging Support 3.4.0_RELEASE from https://java-buildpack.cloudfoundry.org/tomcat-logging-support/tomcat-logging-support-3.4.0-RELEASE.jar (found in cache)
Exit status 0
Uploading droplet, build artifacts cache...
Uploading droplet...
Uploading build artifacts cache...
Uploaded build artifacts cache (29.9M)