Initial provider implementation (#18)

This brings over the initial buildx prototype from pulumi/pulumi-docker
and fixes various build and release issues.
This commit is contained in:
Bryce Lampe
2024-04-25 11:03:59 -07:00
committed by GitHub
parent 2545dd3089
commit 26c144c916
398 changed files with 65361 additions and 1702 deletions

View File

@@ -0,0 +1,187 @@
name: provider-docker-build
runtime: yaml
plugins:
providers:
- name: docker-build
path: ../../bin
resources:
# docker buildx build -f app/Dockerfile.multiPlatform --platform plan9/amd64,plan9/386 app
multiPlatform:
type: docker-build:Image
properties:
push: false
dockerfile:
location: "./app/Dockerfile.multiPlatform"
context:
location: "./app"
platforms:
- plan9/amd64
- plan9/386
# docker buildx build --output=type=registry app
registryPush:
type: docker-build:Image
properties:
push: false
context:
location: "./app"
tags: ["docker.io/pulumibot/buildkit-e2e:example"]
exports:
- registry:
ociMediaTypes: true
push: false # Omit this to actually push images.
# docker buildx build --cache-to=type=local,dest=tmp/cache,mode=max --cache-from=type=local,src=tmp/cache app
cached:
type: docker-build:Image
properties:
push: false
context:
location: "./app"
cacheTo:
- local:
dest: tmp/cache
mode: max
cacheFrom:
- local:
src: tmp/cache
# docker buildx build -f app/Dockerfile.buildArgs --build-arg SET_ME_TO_TRUE=true app
buildArgs:
type: docker-build:Image
properties:
push: false
dockerfile:
location: "./app/Dockerfile.buildArgs"
context:
location: "./app"
buildArgs:
SET_ME_TO_TRUE: "true"
# docker buildx build -f app/Dockerfile.extraHosts --add-host metadata.google.internal:169.254.169.254 app
extraHosts:
type: docker-build:Image
properties:
push: false
dockerfile:
location: "./app/Dockerfile.extraHosts"
context:
location: "./app"
addHosts:
- "metadata.google.internal:169.254.169.254"
# docker buildx build -f app/Dockerfile.sshMount --ssh default app
sshMount:
type: docker-build:Image
properties:
push: false
dockerfile:
location: "./app/Dockerfile.sshMount"
context:
location: "./app"
ssh:
- id: default
# PASSWORD=hunter2 docker buildx build -f app/Dockerfile.secrets --secret id=password,env=PASSWORD app
secrets:
type: docker-build:Image
properties:
push: false
dockerfile:
location: "./app/Dockerfile.secrets"
context:
location: "./app"
secrets:
password: hunter2
# docker buildx build --label "description=This image will get a descriptive label 👍" app
labels:
type: docker-build:Image
properties:
push: false
context:
location: "./app"
labels:
description: "This image will get a descriptive label 👍"
# docker buildx build -f app/Dockerfile.target --target build-me app
target:
type: docker-build:Image
properties:
push: false
dockerfile:
location: "./app/Dockerfile.target"
context:
location: "./app"
target: "build-me"
# docker buildx build -f app/Dockerfile.namedContexts \
# --build-context golang:latest=docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984 app
namedContexts:
type: docker-build:Image
properties:
push: false
dockerfile:
location: "./app/Dockerfile.namedContexts"
context:
location: "./app"
named:
"golang:latest":
location: "docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984"
# docker buildx build https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile
remoteContext:
type: docker-build:Image
properties:
push: false
context:
location: "https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile"
# docker buildx build -f - https://github.com/docker-library/hello-world.git <<EOF
# FROM busybox
# COPY hello.c ./
# EOF
remoteContextWithInline:
type: docker-build:Image
properties:
push: false
dockerfile:
inline: |
FROM busybox
COPY hello.c ./
context:
location: "https://github.com/docker-library/hello-world.git"
# echo "FROM alpine" | docker buildx build -f - .
inline:
type: docker-build:Image
properties:
push: false
dockerfile:
inline: |
FROM alpine
RUN echo "This uses an inline Dockerfile! 👍"
context:
location: "./app"
# docker buildx build --load .
dockerLoad:
type: docker-build:Image
properties:
push: false
context:
location: "./app"
exports:
- docker:
tar: true
# docker buildx build - < app/Dockerfile.emptyContext
#emptyContext:
# type: docker-build:Image
# properties:
# file: "app/Dockerfile.emptyContext"
# context: "-"
outputs:
platforms: ${multiPlatform.platforms}

View File

@@ -0,0 +1,15 @@
# YAML Example Program
Test Pulumi program written in YAML for testing this provider locally.
Edit this yaml program to test features of your provider locally. You can run this program using the following command:
```bash
pulumi login
pulumi stack init local
pulumi up
```
Note that unlike the rest of the auto-generated examples in the ./examples directory, this example is not automatically generated. It is intended to be a place for you to test your provider locally.
The remaining examples are language specific examples derived from the `make gen_examples` command supported in this provider's Makefile. These examples are automatically generated and should not be edited directly. To regenerate these examples, run `make gen_examples` in the root of this provider's repository.

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" ]