Dan Anglin
fda0d6a682
This commit adds the new containers stack which now builds the traefik docker image and creates the traefik docker container. Pulumi needed to be downgraded to version 3.2.1 because later versions panic when building the docker image.
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
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
|
|
}
|