Skip to content

Conversation

ebariaux
Copy link
Contributor

@ebariaux ebariaux commented Sep 7, 2025

Motivation

Allow configuring the CMD entry of the generated image config.

Modifications

Added the argument parsing in containertool.swift and pass it to the publish method.
Given the CMD entries are often options themselves, the .remaining parsing strategy is used.
This means this option must be the last.
Also means that in ContainerImageBuilder/main.swift, the order has been altered when building the arguments used to call the containertool process.

Result

Can configure CMD entry, e.g. for a Vapor example

swift package --swift-sdk aarch64-swift-linux-musl build-container-image --repository localhost:5000/hello --cmd "serve" "--env" "production" "--hostname" "0.0.0.0" "--port" "8080"

Fixes: #89

Test Plan

Added a test-containertool-cmd.sh script to perform some basic testing.

! needs to be last option passed to tool, as it might cmd values might be options themselves
@euanh euanh merged commit 622f730 into apple:main Sep 16, 2025
23 checks passed
@euanh
Copy link
Collaborator

euanh commented Sep 16, 2025

Thanks @ebariaux, this is a great improvement.

@euanh euanh added kind/enhancement New feature or request semver/minor Adds new public API. labels Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or request semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

containertool should be able to set the default arguments passed to the entrypoint

2 participants