package docker
import (
"fmt"
"github.com/pulumi/pulumi-docker/sdk/v3/go/docker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// DockerImageInput is the configuration
// used to create the local Gitea docker
// image.
type DockerImageInput struct {
BuildContext pulumi.StringInput
Dockerfile pulumi.StringInput
ImageName pulumi.StringInput
ImageTag pulumi.StringInput
UniqueLabel string
}
// DockerImageOutput contains the details
// of the generated Docker image.
type DockerImageOutput struct {
ImageName pulumi.StringOutput
// CreateDockerImage creates a local Docker image.
func CreateDockerImage(ctx *pulumi.Context, c DockerImageInput) (DockerImageOutput, error) {
var output DockerImageOutput
args := docker.ImageArgs{
ImageName: pulumi.Sprintf("%s:%s", c.ImageName, c.ImageTag),
SkipPush: pulumi.Bool(true),
Build: docker.DockerBuildArgs{
Context: c.BuildContext,
Dockerfile: c.Dockerfile,
},
i, err := docker.NewImage(ctx, fmt.Sprintf("%s_image", c.UniqueLabel), &args)
if err != nil {
return output, fmt.Errorf("unable to create the Docker image for %s...\n%w", c.UniqueLabel, err)
output = DockerImageOutput{
ImageName: i.BaseImageName,
return output, nil