Forklift buildx provider

This commit is contained in:
Bryce Lampe
2024-03-25 11:40:33 -07:00
parent 2b348f84e4
commit d50d156bd8
349 changed files with 61549 additions and 1141 deletions

View File

@@ -1,5 +1,9 @@
name: provider-dockerbuild
runtime: python
config:
dockerHubPassword:
type: string
secret: true
plugins:
providers:
- name: dockerbuild

View File

@@ -1,5 +1,143 @@
import pulumi
import pulumi_dockerbuild as dockerbuild
my_random_resource = dockerbuild.Random("myRandomResource", length=24)
pulumi.export("value", my_random_resource.result)
config = pulumi.Config()
docker_hub_password = config.require("dockerHubPassword")
multi_platform = dockerbuild.Image("multiPlatform",
dockerfile=dockerbuild.DockerfileArgs(
location="./app/Dockerfile.multiPlatform",
),
context=dockerbuild.BuildContextArgs(
location="./app",
),
platforms=[
dockerbuild.Platform.PLAN9_AMD64,
dockerbuild.Platform.PLAN9_386,
])
registry_push = dockerbuild.Image("registryPush",
context=dockerbuild.BuildContextArgs(
location="./app",
),
tags=["docker.io/pulumibot/buildkit-e2e:example"],
exports=[dockerbuild.ExportArgs(
registry=dockerbuild.ExportRegistryArgs(
oci_media_types=True,
push=False,
),
)],
registries=[dockerbuild.RegistryArgs(
address="docker.io",
username="pulumibot",
password=docker_hub_password,
)])
cached = dockerbuild.Image("cached",
context=dockerbuild.BuildContextArgs(
location="./app",
),
cache_to=[dockerbuild.CacheToArgs(
local=dockerbuild.CacheToLocalArgs(
dest="tmp/cache",
mode=dockerbuild.CacheMode.MAX,
),
)],
cache_from=[dockerbuild.CacheFromArgs(
local=dockerbuild.CacheFromLocalArgs(
src="tmp/cache",
),
)])
build_args = dockerbuild.Image("buildArgs",
dockerfile=dockerbuild.DockerfileArgs(
location="./app/Dockerfile.buildArgs",
),
context=dockerbuild.BuildContextArgs(
location="./app",
),
build_args={
"SET_ME_TO_TRUE": "true",
})
extra_hosts = dockerbuild.Image("extraHosts",
dockerfile=dockerbuild.DockerfileArgs(
location="./app/Dockerfile.extraHosts",
),
context=dockerbuild.BuildContextArgs(
location="./app",
),
add_hosts=["metadata.google.internal:169.254.169.254"])
ssh_mount = dockerbuild.Image("sshMount",
dockerfile=dockerbuild.DockerfileArgs(
location="./app/Dockerfile.sshMount",
),
context=dockerbuild.BuildContextArgs(
location="./app",
),
ssh=[dockerbuild.SSHArgs(
id="default",
)])
secrets = dockerbuild.Image("secrets",
dockerfile=dockerbuild.DockerfileArgs(
location="./app/Dockerfile.secrets",
),
context=dockerbuild.BuildContextArgs(
location="./app",
),
secrets={
"password": "hunter2",
})
labels = dockerbuild.Image("labels",
context=dockerbuild.BuildContextArgs(
location="./app",
),
labels={
"description": "This image will get a descriptive label 👍",
})
target = dockerbuild.Image("target",
dockerfile=dockerbuild.DockerfileArgs(
location="./app/Dockerfile.target",
),
context=dockerbuild.BuildContextArgs(
location="./app",
),
target="build-me")
named_contexts = dockerbuild.Image("namedContexts",
dockerfile=dockerbuild.DockerfileArgs(
location="./app/Dockerfile.namedContexts",
),
context=dockerbuild.BuildContextArgs(
location="./app",
named={
"golang:latest": dockerbuild.ContextArgs(
location="docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984",
),
},
))
remote_context = dockerbuild.Image("remoteContext", context=dockerbuild.BuildContextArgs(
location="https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile",
))
remote_context_with_inline = dockerbuild.Image("remoteContextWithInline",
dockerfile=dockerbuild.DockerfileArgs(
inline="""FROM busybox
COPY hello.c ./
""",
),
context=dockerbuild.BuildContextArgs(
location="https://github.com/docker-library/hello-world.git",
))
inline = dockerbuild.Image("inline",
dockerfile=dockerbuild.DockerfileArgs(
inline="""FROM alpine
RUN echo "This uses an inline Dockerfile! 👍"
""",
),
context=dockerbuild.BuildContextArgs(
location="./app",
))
docker_load = dockerbuild.Image("dockerLoad",
context=dockerbuild.BuildContextArgs(
location="./app",
),
exports=[dockerbuild.ExportArgs(
docker=dockerbuild.ExportDockerArgs(
tar=True,
),
)])
pulumi.export("platforms", multi_platform.platforms)

View File

@@ -0,0 +1,2 @@
FROM alpine
RUN echo 👍

View File

@@ -0,0 +1,5 @@
FROM alpine
ARG SET_ME_TO_TRUE
RUN [ "$SET_ME_TO_TRUE" = "true" ]
RUN echo "That's the correct build arg, thanks! 👍"

View File

@@ -0,0 +1,2 @@
FROM alpine
RUN echo "This image doesn't use any local files, so it doesn't need a context parameter 👍"

View File

@@ -0,0 +1,3 @@
FROM bash AS base
RUN getent hosts metadata.google.internal

View File

@@ -0,0 +1,7 @@
FROM --platform=$BUILDPLATFORM alpine as build
RUN echo ${BUILDPLATFORM} > buildplatform
RUN echo ${TARGETPLATFORM} > targetplatform
FROM build
RUN cat buildplatform
RUN cat targetplatform

View File

@@ -0,0 +1,5 @@
# syntax=docker/dockerfile:1.4
FROM golang:latest
RUN version="$(go version)" && echo $version && [ "$version" = "go version go1.21.7 linux/amd64" ]
RUN echo "This image uses named contexts to pin golang:latest to a specific SHA 👍"

View File

@@ -0,0 +1,4 @@
FROM alpine
RUN --mount=type=secret,id=password [ "$(cat /run/secrets/password)" = "hunter2" ]

View File

@@ -0,0 +1,5 @@
FROM alpine
RUN apk add openssh-client
RUN --mount=type=ssh ssh-add -l

View File

@@ -0,0 +1,8 @@
FROM alpine as build-me
RUN echo 👍
FROM build-me as also-build-me
RUN echo 🤙
FROM build-me as dont-build-me
RUN [ "true" = "false" ]