apple / apple/swift-container-plugin

`containertool` could choose a distroless base image for static binaries by default

Open
#102 0 comments 2 reactions 0 assignees View on GitHub
kind/enhancement status/needs-design
Dominant language
Swift
Stars
390
Forks
26
Avg merge
8m
Merged PRs (30d)
1

Description

`containertool` reads the CPU architecture from the ELF header of the target executable in order to find a compatible base image.

It could also check whether the executable is statically- or dynamically-linked and choose a more suitable base image:
* If the executable is dynamically linked, use an image which provides the standard Linux dynamic libraries and the Swift runtime
* If the executable is dynamically linked, but with the Swift runtime linked in (`--static-swift-stdlib`), use a generic Linux base image without a Swift runtime
* If the executable is statically linked, use a distroless base image which only provides a bare minimum of resources, such as a root certificate bundle.

This would require `containertool` to be able to parse the program header (linking type), and possibly section header (linked libraries), whereas currently it only reads part of the overall ELF header.

Contributor guide

Open the contributing guide

Research direction

Start by locating containertool's existing ELF-header parsing and base-image selection, then inspect how program headers and, if needed, section headers expose static or dynamic linking. Done means selecting suitable Swift-runtime, generic Linux, or distroless images for the three linking cases while preserving architecture compatibility; no test file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system, devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.