plugin: Add resource bundles defined in Package.swift to container images#78
Merged
euanh merged 4 commits intoapple:mainfrom Apr 11, 2025
Merged
plugin: Add resource bundles defined in Package.swift to container images#78euanh merged 4 commits intoapple:mainfrom
euanh merged 4 commits intoapple:mainfrom
Conversation
5de57c3 to
43e7d4f
Compare
8196e0a to
67f072e
Compare
Alternatively: check the target input file list for resource files.
7f298e6 to
320ad63
Compare
euanh
added a commit
that referenced
this pull request
Apr 14, 2025
Motivation ---------- An example showing how to use resources (#78) is helpful for new users and can be used as an end to end tests for this feature. Modifications ------------- * Add a new `HelloWorldWithResources` example * Add the new example to the `End to end tests` GitHub Actions job * Restructure the end to end tests to check the HTTP response code instead of the content which is returned, because the new test returns one of 3 JPEGs selected at random, whereas the existing tests returned strings. * Adopt the code structure used by the [official Hummingbird examples](https://github.com/hummingbird-project/hummingbird-examples), to make it more familiar to users who are used to the official examples. Result ------ * The repository contains a new example showing how to use resources in a container image * The resource feature is tested as part of the automated end to end test suite. Test Plan --------- The new test passes and all existing tests continue to pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
A target in
Package.swiftcan include resources. When the target is built, the resources are copied into a bundle directory and aBundleclass is generated, giving the executable a convenient way to retrieve them at run time.A target with resources should be able to access them when it is packaged in a container image. For example, a web server might bundle resources such as images or fonts.
Fixes #48
Modifications
--resourceparameter tocontainertool. This specifies a resource bundle directory which is added to the container image using the directory archiving support added to theTarmodule in tar: Add support for archiving directories #74. Whencontainertoolis used alone, multiple--resourceflags can be specified and will be added to the image in the order in which they appear on the command line. A target inPackage.swiftcan only define one resource bundle, so when used through the plugin only one bundle will be added.--resourceflag tocontainertoolwhen an executable target has resources.Result
If a target includes resources, the resource bundle will be copied into the container image at a path where the generated
Bundleclass can find it.If a target does not include resources, the container image will only include the executable.
Test Plan