docker-build.Index
Explore with Pulumi AI
A wrapper around docker buildx imagetools create
to create an index
(or manifest list) referencing one or more existing images.
In most cases you do not need an Index
to build a multi-platform
image – specifying multiple platforms on the Image
will handle this
for you automatically.
However, as of April 2024, building multi-platform images with caching will only export a cache for one platform at a time (see this discussion for more details).
Therefore this resource can be helpful if you are building
multi-platform images with caching: each platform can be built and
cached separately, and an Index
can join them all together. An
example of this is shown below.
This resource creates an OCI image index or a Docker manifest list depending on the media types of the source images.
Example Usage
Multi-platform registry caching
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DockerBuild = Pulumi.DockerBuild;
return await Deployment.RunAsync(() =>
{
var amd64 = new DockerBuild.Image("amd64", new()
{
CacheFrom = new[]
{
new DockerBuild.Inputs.CacheFromArgs
{
Registry = new DockerBuild.Inputs.CacheFromRegistryArgs
{
Ref = "docker.io/pulumi/pulumi:cache-amd64",
},
},
},
CacheTo = new[]
{
new DockerBuild.Inputs.CacheToArgs
{
Registry = new DockerBuild.Inputs.CacheToRegistryArgs
{
Mode = DockerBuild.CacheMode.Max,
Ref = "docker.io/pulumi/pulumi:cache-amd64",
},
},
},
Context = new DockerBuild.Inputs.BuildContextArgs
{
Location = "app",
},
Platforms = new[]
{
DockerBuild.Platform.Linux_amd64,
},
Tags = new[]
{
"docker.io/pulumi/pulumi:3.107.0-amd64",
},
});
var arm64 = new DockerBuild.Image("arm64", new()
{
CacheFrom = new[]
{
new DockerBuild.Inputs.CacheFromArgs
{
Registry = new DockerBuild.Inputs.CacheFromRegistryArgs
{
Ref = "docker.io/pulumi/pulumi:cache-arm64",
},
},
},
CacheTo = new[]
{
new DockerBuild.Inputs.CacheToArgs
{
Registry = new DockerBuild.Inputs.CacheToRegistryArgs
{
Mode = DockerBuild.CacheMode.Max,
Ref = "docker.io/pulumi/pulumi:cache-arm64",
},
},
},
Context = new DockerBuild.Inputs.BuildContextArgs
{
Location = "app",
},
Platforms = new[]
{
DockerBuild.Platform.Linux_arm64,
},
Tags = new[]
{
"docker.io/pulumi/pulumi:3.107.0-arm64",
},
});
var index = new DockerBuild.Index("index", new()
{
Sources = new[]
{
amd64.Ref,
arm64.Ref,
},
Tag = "docker.io/pulumi/pulumi:3.107.0",
});
return new Dictionary<string, object?>
{
["ref"] = index.Ref,
};
});
package main
import (
"github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
amd64, err := dockerbuild.NewImage(ctx, "amd64", &dockerbuild.ImageArgs{
CacheFrom: dockerbuild.CacheFromArray{
&dockerbuild.CacheFromArgs{
Registry: &dockerbuild.CacheFromRegistryArgs{
Ref: pulumi.String("docker.io/pulumi/pulumi:cache-amd64"),
},
},
},
CacheTo: dockerbuild.CacheToArray{
&dockerbuild.CacheToArgs{
Registry: &dockerbuild.CacheToRegistryArgs{
Mode: dockerbuild.CacheModeMax,
Ref: pulumi.String("docker.io/pulumi/pulumi:cache-amd64"),
},
},
},
Context: &dockerbuild.BuildContextArgs{
Location: pulumi.String("app"),
},
Platforms: docker - build.PlatformArray{
dockerbuild.Platform_Linux_amd64,
},
Tags: pulumi.StringArray{
pulumi.String("docker.io/pulumi/pulumi:3.107.0-amd64"),
},
})
if err != nil {
return err
}
arm64, err := dockerbuild.NewImage(ctx, "arm64", &dockerbuild.ImageArgs{
CacheFrom: dockerbuild.CacheFromArray{
&dockerbuild.CacheFromArgs{
Registry: &dockerbuild.CacheFromRegistryArgs{
Ref: pulumi.String("docker.io/pulumi/pulumi:cache-arm64"),
},
},
},
CacheTo: dockerbuild.CacheToArray{
&dockerbuild.CacheToArgs{
Registry: &dockerbuild.CacheToRegistryArgs{
Mode: dockerbuild.CacheModeMax,
Ref: pulumi.String("docker.io/pulumi/pulumi:cache-arm64"),
},
},
},
Context: &dockerbuild.BuildContextArgs{
Location: pulumi.String("app"),
},
Platforms: docker - build.PlatformArray{
dockerbuild.Platform_Linux_arm64,
},
Tags: pulumi.StringArray{
pulumi.String("docker.io/pulumi/pulumi:3.107.0-arm64"),
},
})
if err != nil {
return err
}
index, err := dockerbuild.NewIndex(ctx, "index", &dockerbuild.IndexArgs{
Sources: pulumi.StringArray{
amd64.Ref,
arm64.Ref,
},
Tag: pulumi.String("docker.io/pulumi/pulumi:3.107.0"),
})
if err != nil {
return err
}
ctx.Export("ref", index.Ref)
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.dockerbuild.Image;
import com.pulumi.dockerbuild.ImageArgs;
import com.pulumi.dockerbuild.inputs.CacheFromArgs;
import com.pulumi.dockerbuild.inputs.CacheFromRegistryArgs;
import com.pulumi.dockerbuild.inputs.CacheToArgs;
import com.pulumi.dockerbuild.inputs.CacheToRegistryArgs;
import com.pulumi.dockerbuild.inputs.BuildContextArgs;
import com.pulumi.dockerbuild.Index;
import com.pulumi.dockerbuild.IndexArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var amd64 = new Image("amd64", ImageArgs.builder()
.cacheFrom(CacheFromArgs.builder()
.registry(CacheFromRegistryArgs.builder()
.ref("docker.io/pulumi/pulumi:cache-amd64")
.build())
.build())
.cacheTo(CacheToArgs.builder()
.registry(CacheToRegistryArgs.builder()
.mode("max")
.ref("docker.io/pulumi/pulumi:cache-amd64")
.build())
.build())
.context(BuildContextArgs.builder()
.location("app")
.build())
.platforms("linux/amd64")
.tags("docker.io/pulumi/pulumi:3.107.0-amd64")
.build());
var arm64 = new Image("arm64", ImageArgs.builder()
.cacheFrom(CacheFromArgs.builder()
.registry(CacheFromRegistryArgs.builder()
.ref("docker.io/pulumi/pulumi:cache-arm64")
.build())
.build())
.cacheTo(CacheToArgs.builder()
.registry(CacheToRegistryArgs.builder()
.mode("max")
.ref("docker.io/pulumi/pulumi:cache-arm64")
.build())
.build())
.context(BuildContextArgs.builder()
.location("app")
.build())
.platforms("linux/arm64")
.tags("docker.io/pulumi/pulumi:3.107.0-arm64")
.build());
var index = new Index("index", IndexArgs.builder()
.sources(
amd64.ref(),
arm64.ref())
.tag("docker.io/pulumi/pulumi:3.107.0")
.build());
ctx.export("ref", index.ref());
}
}
import pulumi
import pulumi_docker_build as docker_build
amd64 = docker_build.Image("amd64",
cache_from=[{
"registry": {
"ref": "docker.io/pulumi/pulumi:cache-amd64",
},
}],
cache_to=[{
"registry": {
"mode": docker_build.CacheMode.MAX,
"ref": "docker.io/pulumi/pulumi:cache-amd64",
},
}],
context={
"location": "app",
},
platforms=[docker_build.Platform.LINUX_AMD64],
tags=["docker.io/pulumi/pulumi:3.107.0-amd64"])
arm64 = docker_build.Image("arm64",
cache_from=[{
"registry": {
"ref": "docker.io/pulumi/pulumi:cache-arm64",
},
}],
cache_to=[{
"registry": {
"mode": docker_build.CacheMode.MAX,
"ref": "docker.io/pulumi/pulumi:cache-arm64",
},
}],
context={
"location": "app",
},
platforms=[docker_build.Platform.LINUX_ARM64],
tags=["docker.io/pulumi/pulumi:3.107.0-arm64"])
index = docker_build.Index("index",
sources=[
amd64.ref,
arm64.ref,
],
tag="docker.io/pulumi/pulumi:3.107.0")
pulumi.export("ref", index.ref)
import * as pulumi from "@pulumi/pulumi";
import * as docker_build from "@pulumi/docker-build";
const amd64 = new docker_build.Image("amd64", {
cacheFrom: [{
registry: {
ref: "docker.io/pulumi/pulumi:cache-amd64",
},
}],
cacheTo: [{
registry: {
mode: docker_build.CacheMode.Max,
ref: "docker.io/pulumi/pulumi:cache-amd64",
},
}],
context: {
location: "app",
},
platforms: [docker_build.Platform.Linux_amd64],
tags: ["docker.io/pulumi/pulumi:3.107.0-amd64"],
});
const arm64 = new docker_build.Image("arm64", {
cacheFrom: [{
registry: {
ref: "docker.io/pulumi/pulumi:cache-arm64",
},
}],
cacheTo: [{
registry: {
mode: docker_build.CacheMode.Max,
ref: "docker.io/pulumi/pulumi:cache-arm64",
},
}],
context: {
location: "app",
},
platforms: [docker_build.Platform.Linux_arm64],
tags: ["docker.io/pulumi/pulumi:3.107.0-arm64"],
});
const index = new docker_build.Index("index", {
sources: [
amd64.ref,
arm64.ref,
],
tag: "docker.io/pulumi/pulumi:3.107.0",
});
export const ref = index.ref;
description: Multi-platform registry caching
name: registry-caching
outputs:
ref: ${index.ref}
resources:
amd64:
properties:
cacheFrom:
- registry:
ref: docker.io/pulumi/pulumi:cache-amd64
cacheTo:
- registry:
mode: max
ref: docker.io/pulumi/pulumi:cache-amd64
context:
location: app
platforms:
- linux/amd64
tags:
- docker.io/pulumi/pulumi:3.107.0-amd64
type: docker-build:Image
arm64:
properties:
cacheFrom:
- registry:
ref: docker.io/pulumi/pulumi:cache-arm64
cacheTo:
- registry:
mode: max
ref: docker.io/pulumi/pulumi:cache-arm64
context:
location: app
platforms:
- linux/arm64
tags:
- docker.io/pulumi/pulumi:3.107.0-arm64
type: docker-build:Image
index:
properties:
sources:
- ${amd64.ref}
- ${arm64.ref}
tag: docker.io/pulumi/pulumi:3.107.0
type: docker-build:Index
runtime: yaml
Create Index Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Index(name: string, args: IndexArgs, opts?: CustomResourceOptions);
@overload
def Index(resource_name: str,
args: IndexArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Index(resource_name: str,
opts: Optional[ResourceOptions] = None,
sources: Optional[Sequence[str]] = None,
tag: Optional[str] = None,
push: Optional[bool] = None,
registry: Optional[RegistryArgs] = None)
func NewIndex(ctx *Context, name string, args IndexArgs, opts ...ResourceOption) (*Index, error)
public Index(string name, IndexArgs args, CustomResourceOptions? opts = null)
type: docker-build:Index
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args IndexArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args IndexArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args IndexArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args IndexArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args IndexArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var indexResource = new DockerBuild.Index("indexResource", new()
{
Sources = new[]
{
"string",
},
Tag = "string",
Push = false,
Registry = new DockerBuild.Inputs.RegistryArgs
{
Address = "string",
Password = "string",
Username = "string",
},
});
example, err := dockerbuild.NewIndex(ctx, "indexResource", &dockerbuild.IndexArgs{
Sources: pulumi.StringArray{
pulumi.String("string"),
},
Tag: pulumi.String("string"),
Push: pulumi.Bool(false),
Registry: &dockerbuild.RegistryArgs{
Address: pulumi.String("string"),
Password: pulumi.String("string"),
Username: pulumi.String("string"),
},
})
var indexResource = new Index("indexResource", IndexArgs.builder()
.sources("string")
.tag("string")
.push(false)
.registry(RegistryArgs.builder()
.address("string")
.password("string")
.username("string")
.build())
.build());
index_resource = docker_build.Index("indexResource",
sources=["string"],
tag="string",
push=False,
registry={
"address": "string",
"password": "string",
"username": "string",
})
const indexResource = new docker_build.Index("indexResource", {
sources: ["string"],
tag: "string",
push: false,
registry: {
address: "string",
password: "string",
username: "string",
},
});
type: docker-build:Index
properties:
push: false
registry:
address: string
password: string
username: string
sources:
- string
tag: string
Index Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Index resource accepts the following input properties:
- Sources List<string>
- Existing images to include in the index.
- Tag string
- The tag to apply to the index.
- Push bool
If true, push the index to the target registry.
Defaults to
true
.- Registry
Pulumi.
Docker Build. Inputs. Registry Authentication for the registry where the tagged index will be pushed.
Credentials can also be included with the provider's configuration.
- Sources []string
- Existing images to include in the index.
- Tag string
- The tag to apply to the index.
- Push bool
If true, push the index to the target registry.
Defaults to
true
.- Registry
Registry
Args Authentication for the registry where the tagged index will be pushed.
Credentials can also be included with the provider's configuration.
- sources List<String>
- Existing images to include in the index.
- tag String
- The tag to apply to the index.
- push Boolean
If true, push the index to the target registry.
Defaults to
true
.- registry Registry
Authentication for the registry where the tagged index will be pushed.
Credentials can also be included with the provider's configuration.
- sources string[]
- Existing images to include in the index.
- tag string
- The tag to apply to the index.
- push boolean
If true, push the index to the target registry.
Defaults to
true
.- registry Registry
Authentication for the registry where the tagged index will be pushed.
Credentials can also be included with the provider's configuration.
- sources Sequence[str]
- Existing images to include in the index.
- tag str
- The tag to apply to the index.
- push bool
If true, push the index to the target registry.
Defaults to
true
.- registry
Registry
Args Authentication for the registry where the tagged index will be pushed.
Credentials can also be included with the provider's configuration.
- sources List<String>
- Existing images to include in the index.
- tag String
- The tag to apply to the index.
- push Boolean
If true, push the index to the target registry.
Defaults to
true
.- registry Property Map
Authentication for the registry where the tagged index will be pushed.
Credentials can also be included with the provider's configuration.
Outputs
All input properties are implicitly available as output properties. Additionally, the Index resource produces the following output properties:
Supporting Types
Registry, RegistryArgs
Package Details
- Repository
- docker-build pulumi/pulumi-docker-build
- License
- Apache-2.0