Skip to content

Support multi-arch Components #106

@samalba

Description

@samalba

With the growing number of arm machines, it's critical to support multi-arch builds.

From the simple example in the repo:

#alpine: dagger.#Component & {
	version: "3.13.1@sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436"
	package: [string]: true | false | string
	#dagger: compute: [
		{
			do: "fetch-container"
			ref: "index.docker.io/alpine\(version)"
		},
		for pkg, info in package {
			if (info & true) != _|_ {
				do: "exec"
				args: ["apk", "add", "-U", "--no-cache", pkg]
			}
			if (info & string) != _|_  {
				do: "exec"
				args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"]
			}
		},
	]
}

Here the base image implicitly points to x86 because of the digest.

Then, a dagger component is likely to be arch specific, for instance:

#awsCli: {
	version: *"2.1.23" | string
	#dagger: compute: [
		dagger.#Load & {
			from: #alpine & {
				package: {
					jq: true
					bash: true
					curl: true
					"libc6-compat": true
				}
			}
		},
		dagger.#Exec & {
			args: ["bash", "-c", """
				cd /tmp; curl -sfL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-\(version).zip" -o aws.zip &&
				unzip aws.zip &&
				./aws/install
				rm -rf aws*
				"""
			]
		}
	]
}

This will only work on x86. We need a way to auto-select Components and based images depending on the host arch so we can write multi-arch components.

buildkit's Dockerfile is a good example: https://github.com/moby/buildkit/blob/master/Dockerfile

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions