Skip to content

Commit 150be36

Browse files
authored
feat: adopt selective dependency packaging (profiles) (#1228)
* architecture document for adding exclusions and profiles for offline buildpacks * feat: adopt selective dependency packaging profiles Add packaging_profiles to manifest.yml and wire --profile/--exclude/--include flags through scripts/package.sh to buildpack-packager. Depends on libbuildpack PR cloudfoundry/libbuildpack#212 which introduces PackageWithOptions, resolveExclusions, and the three new CLI flags in buildpack-packager. Changes: - manifest.yml: add packaging_profiles section with 'minimal' (28 deps) and 'standard' (32 deps) profiles - scripts/package.sh: parse and forward --profile, --exclude, --include to buildpack-packager; update usage() - README.md: document selective offline packaging, updated --help output and package examples - docs/DEVELOPING.md: document profile/exclude options in packaging section - docs/buildpack-modes.md: add Selective Offline Packaging subsection
1 parent 1cf1b00 commit 150be36

6 files changed

Lines changed: 1081 additions & 4 deletions

File tree

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,48 @@ Building buildpack (version: 0.0.0, stack: cflinuxfs4, cached: true, output: bui
233233

234234
The offline package will be significantly larger (1.0-1.2 GB depending on cached dependencies) as it includes all JRE versions and framework agents specified in `manifest.yml`.
235235

236+
#### Selective Dependency Packaging
237+
238+
For air-gapped environments or security-conscious deployments, you can build a smaller offline package that contains only a named subset of dependencies using packaging profiles or explicit exclusions.
239+
240+
**Using a profile** (defined in `manifest.yml`):
241+
242+
```bash
243+
# Minimal: JDKs, CF utilities, Tomcat, and common frameworks only (~28 dependencies)
244+
$ ./scripts/package.sh --cached --profile minimal
245+
246+
# Standard: core + open-source APM, OTel, and JDBC drivers (~32 dependencies)
247+
$ ./scripts/package.sh --cached --profile standard
248+
```
249+
250+
**Ad-hoc exclusions** (no profile required):
251+
252+
```bash
253+
# Exclude specific agents you don't have licences for
254+
$ ./scripts/package.sh --cached --exclude jrebel,your-kit-profiler,jprofiler-profiler
255+
```
256+
257+
**Combining a profile with overrides**:
258+
259+
```bash
260+
# Start from standard profile but also drop jacoco
261+
$ ./scripts/package.sh --cached --profile standard --exclude jacoco
262+
263+
# Start from minimal profile but add back jprofiler for triage builds
264+
$ ./scripts/package.sh --cached --profile minimal --include jprofiler-profiler
265+
```
266+
267+
The output zip filename reflects the profile/exclusion applied so that different variants can coexist:
268+
269+
| Invocation | Output filename |
270+
|---|---|
271+
| `--cached` | `java_buildpack-cached-cflinuxfs4-v<ver>.zip` |
272+
| `--cached --profile minimal` | `java_buildpack-cached-minimal-cflinuxfs4-v<ver>.zip` |
273+
| `--cached --exclude newrelic` | `java_buildpack-cached-custom-cflinuxfs4-v<ver>.zip` |
274+
| `--cached --profile minimal --include jprofiler-profiler` | `java_buildpack-cached-minimal+custom-cflinuxfs4-v<ver>.zip` |
275+
276+
> **Note**: `--profile`, `--exclude`, and `--include` are only valid with `--cached`. Using them on an uncached build is an error. `--include` requires `--profile` to be set.
277+
236278
### Package Versioning
237279
To specify a version number when creating a package, use the `--version` flag:
238280

@@ -260,6 +302,9 @@ OPTIONS
260302
--cached cache the buildpack dependencies (default: false)
261303
--stack <stack> specifies the stack (default: cflinuxfs4)
262304
--output <file> output file path (default: build/buildpack.zip)
305+
--profile <name> packaging profile from manifest.yml (e.g. minimal, standard)
306+
--exclude <dep1,dep2,...> comma-separated dependency names to exclude (cached only)
307+
--include <dep1,dep2,...> comma-separated dependency names to restore, overriding profile exclusions (cached only)
263308
```
264309

265310
### Customizing Dependencies
@@ -289,14 +334,26 @@ dependencies:
289334
# Online package with version 5.0.0
290335
$ ./scripts/package.sh --version 5.0.0
291336
292-
# Offline package with version 5.0.0
337+
# Offline package with version 5.0.0 (all dependencies)
293338
$ ./scripts/package.sh --version 5.0.0 --cached
294339
295340
# Package for specific stack
296341
$ ./scripts/package.sh --stack cflinuxfs4 --cached
297342
298343
# Custom output location
299344
$ ./scripts/package.sh --version 5.0.0 --cached --output /tmp/my-buildpack.zip
345+
346+
# Offline package with minimal profile (JDKs + CF utilities only)
347+
$ ./scripts/package.sh --version 5.0.0 --cached --profile minimal
348+
349+
# Offline package with standard profile (core + open-source observability)
350+
$ ./scripts/package.sh --version 5.0.0 --cached --profile standard
351+
352+
# Exclude specific dependencies without a profile
353+
$ ./scripts/package.sh --version 5.0.0 --cached --exclude jrebel,your-kit-profiler
354+
355+
# Minimal profile, but add back jprofiler for this specific build
356+
$ ./scripts/package.sh --version 5.0.0 --cached --profile minimal --include jprofiler-profiler
300357
```
301358

302359
## Running Tests

docs/DEVELOPING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,28 @@ Create a package with all dependencies cached (no internet required at runtime):
482482

483483
**Output:** `build/buildpack.zip` (~500MB, varies based on cached dependencies)
484484

485+
#### Selective Dependency Packaging (Profiles)
486+
487+
For environments that only need a subset of dependencies, use packaging profiles or
488+
explicit exclusions to reduce the offline package size:
489+
490+
```bash
491+
# Minimal: JDKs, CF utilities, Tomcat only (~28 deps, much smaller download)
492+
./scripts/package.sh --version 1.0.0 --cached --profile minimal
493+
494+
# Standard: core + open-source APM, OTel, JDBC (~32 deps)
495+
./scripts/package.sh --version 1.0.0 --cached --profile standard
496+
497+
# Ad-hoc: exclude specific agents (no profile needed)
498+
./scripts/package.sh --version 1.0.0 --cached --exclude jrebel,your-kit-profiler
499+
500+
# Restore one dep excluded by a profile
501+
./scripts/package.sh --version 1.0.0 --cached --profile minimal --include jprofiler-profiler
502+
```
503+
504+
Profiles are declared in the `packaging_profiles` section of `manifest.yml`. See
505+
[Selective Dependency Packaging](selective-dependency-packaging.md) for full details.
506+
485507
### Package Options
486508

487509
```bash
@@ -496,6 +518,12 @@ Create a package with all dependencies cached (no internet required at runtime):
496518

497519
# Offline with custom stack
498520
./scripts/package.sh --version 1.0.0 --cached --stack cflinuxfs4
521+
522+
# Offline with minimal profile
523+
./scripts/package.sh --version 1.0.0 --cached --profile minimal
524+
525+
# Offline excluding specific dependencies
526+
./scripts/package.sh --version 1.0.0 --cached --exclude datadog-javaagent,newrelic
499527
```
500528

501529
### Automated Packaging (CI/CD)

docs/buildpack-modes.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,39 @@ The "Offline Mode" buildpack is a self-contained packaging of either the "Easy M
4444

4545
You can download specific versions of the "Offline Mode" buildpack to use with the `create-buildpack` and `update-buildpack` Cloud Foundry CLI commands. To find these, navigate to the [Java Buildpack Releases page][v] and download one of the `java-buildpack-offline-v<VERSION>.zip` file. In order to package a modified "Offline Mode" buildpack, refer to [Building Packages][p]. To add the buildpack to an instance of Cloud Foundry, use the `cf create-buildpack java-buildpack java-buildpack-offline-v<VERSION>.zip` command. For more details refer to the [Cloud Foundry buildpack documentation][b].
4646

47+
### Selective Offline Packaging
48+
49+
The full offline package bundles every dependency in `manifest.yml` (~47 binaries, 1.0-1.2 GB). For
50+
air-gapped environments that only need a subset, you can build a smaller offline package using
51+
**packaging profiles** or explicit exclusions.
52+
53+
**Using a profile** (defined in `manifest.yml`'s `packaging_profiles` section):
54+
55+
```bash
56+
# Minimal: JDKs, CF utilities, Tomcat, and common frameworks only (~28 deps)
57+
$ ./scripts/package.sh --cached --profile minimal
58+
59+
# Standard: core + open-source APM, OTel, and JDBC drivers (~32 deps)
60+
$ ./scripts/package.sh --cached --profile standard
61+
```
62+
63+
**Ad-hoc exclusions** without a profile:
64+
65+
```bash
66+
# Remove specific agents you don't have licences for
67+
$ ./scripts/package.sh --cached --exclude jrebel,your-kit-profiler,jprofiler-profiler
68+
```
69+
70+
**Overriding a profile** to restore a specific dependency:
71+
72+
```bash
73+
# Start from minimal but include jprofiler for triage builds
74+
$ ./scripts/package.sh --cached --profile minimal --include jprofiler-profiler
75+
```
76+
77+
For full details on profiles, validation rules, and output filename conventions, see
78+
[Selective Dependency Packaging](selective-dependency-packaging.md).
79+
4780

4881
[b]: http://docs.pivotal.io/pivotalcf/adminguide/buildpacks.html
4982
[c]: ../README.md#configuration-and-extension

0 commit comments

Comments
 (0)