Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ Whether to verify TLS certificates.

Default: `true`

### `platform` (optional)

Specify the architecture of the image to pull

### `types` (optional)

The types of artifacts to build. Can be any type supported by
Expand Down
7 changes: 6 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/types.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions src/bib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export async function build(

// Pull the required images
core.startGroup('Pulling required images')
await pullImage(options.builderImage, options.tlsVerify)
await pullImage(options.image, options.tlsVerify)
await pullImage(options.builderImage, options.tlsVerify, options.platform)
await pullImage(options.image, options.tlsVerify, options.platform)
core.endGroup()

// Create the output directory
Expand All @@ -43,6 +43,9 @@ export async function build(
podmanArgs.push('run')
podmanArgs.push('--rm')
podmanArgs.push('--privileged')
if (options.platform) {
podmanArgs.push(`--platform ${options.platform}`)
}
podmanArgs.push('--security-opt label=type:unconfined_t')
podmanArgs.push(
'--volume /var/lib/containers/storage:/var/lib/containers/storage'
Expand Down Expand Up @@ -126,15 +129,18 @@ export async function build(
}
}
}

// Pull an image using podman
async function pullImage(image: string, tlsVerify?: boolean): Promise<void> {
async function pullImage(
image: string,
tlsVerify?: boolean,
platform?: string
): Promise<void> {
try {
const executible = 'podman'
const tlsFlags = tlsVerify ? '' : '--tls-verify=false'
const platformFlag = platform ? `--platform ${platform}` : ''
await execAsRoot(
executible,
['pull', tlsFlags, image].filter((arg) => arg)
['pull', tlsFlags, platformFlag, image].filter((arg) => arg)
)
} catch (error) {
core.setFailed(`Failed to pull image ${image}: ${(error as Error).message}`)
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export async function run(): Promise<void> {
const configFilePath: string = core.getInput('config-file')
const image: string = core.getInput('image')
const builderImage: string = core.getInput('builder-image')
const platform: string = core.getInput('platform') || 'linux/amd64'
Copy link
Collaborator

@p5 p5 Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be best if this defaults to null or an empty string if the input is not found, rather than always linux/amd64.
Then elsewhere in the code, include conditions like (pseudocode):

if platform != null {
  podmanArgs.push("--platform ${platform}")
}

const additionalArgs: string = core.getInput('additional-args')
const chown: string = core.getInput('chown')
const rootfs: string = core.getInput('rootfs')
Expand All @@ -34,6 +35,7 @@ export async function run(): Promise<void> {
configFilePath,
image,
builderImage,
platform,
additionalArgs,
chown,
rootfs,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface BootcImageBuilderOptions {
platform?: string
configFilePath: string
image: string
builderImage: string
Expand Down