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:
@@ -1,6 +1,10 @@
|
||||
name: provider-dockerbuild
|
||||
name: provider-docker-build
|
||||
runtime: nodejs
|
||||
config:
|
||||
dockerHubPassword:
|
||||
type: string
|
||||
secret: true
|
||||
plugins:
|
||||
providers:
|
||||
- name: dockerbuild
|
||||
- name: docker-build
|
||||
path: ../../bin
|
||||
|
||||
2
examples/nodejs/app/Dockerfile
Normal file
2
examples/nodejs/app/Dockerfile
Normal file
@@ -0,0 +1,2 @@
|
||||
FROM alpine
|
||||
RUN echo 👍
|
||||
5
examples/nodejs/app/Dockerfile.buildArgs
Normal file
5
examples/nodejs/app/Dockerfile.buildArgs
Normal 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! 👍"
|
||||
2
examples/nodejs/app/Dockerfile.emptyContext
Normal file
2
examples/nodejs/app/Dockerfile.emptyContext
Normal 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 👍"
|
||||
3
examples/nodejs/app/Dockerfile.extraHosts
Normal file
3
examples/nodejs/app/Dockerfile.extraHosts
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM bash AS base
|
||||
|
||||
RUN getent hosts metadata.google.internal
|
||||
7
examples/nodejs/app/Dockerfile.multiPlatform
Normal file
7
examples/nodejs/app/Dockerfile.multiPlatform
Normal 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
|
||||
5
examples/nodejs/app/Dockerfile.namedContexts
Normal file
5
examples/nodejs/app/Dockerfile.namedContexts
Normal 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 👍"
|
||||
4
examples/nodejs/app/Dockerfile.secrets
Normal file
4
examples/nodejs/app/Dockerfile.secrets
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM alpine
|
||||
|
||||
RUN --mount=type=secret,id=password [ "$(cat /run/secrets/password)" = "hunter2" ]
|
||||
|
||||
5
examples/nodejs/app/Dockerfile.sshMount
Normal file
5
examples/nodejs/app/Dockerfile.sshMount
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM alpine
|
||||
|
||||
RUN apk add openssh-client
|
||||
|
||||
RUN --mount=type=ssh ssh-add -l
|
||||
8
examples/nodejs/app/Dockerfile.target
Normal file
8
examples/nodejs/app/Dockerfile.target
Normal 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" ]
|
||||
@@ -1,5 +1,172 @@
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
import * as dockerbuild from "@pulumi/dockerbuild";
|
||||
import * as docker_build from "@pulumi/docker-build";
|
||||
|
||||
const myRandomResource = new dockerbuild.Random("myRandomResource", {length: 24});
|
||||
export const value = myRandomResource.result;
|
||||
const config = new pulumi.Config();
|
||||
const dockerHubPassword = config.require("dockerHubPassword");
|
||||
const multiPlatform = new docker_build.Image("multiPlatform", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
location: "./app/Dockerfile.multiPlatform",
|
||||
},
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
platforms: [
|
||||
docker_build.Platform.Plan9_amd64,
|
||||
docker_build.Platform.Plan9_386,
|
||||
],
|
||||
});
|
||||
const registryPush = new docker_build.Image("registryPush", {
|
||||
push: false,
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
tags: ["docker.io/pulumibot/buildkit-e2e:example"],
|
||||
exports: [{
|
||||
registry: {
|
||||
ociMediaTypes: true,
|
||||
push: false,
|
||||
},
|
||||
}],
|
||||
registries: [{
|
||||
address: "docker.io",
|
||||
username: "pulumibot",
|
||||
password: dockerHubPassword,
|
||||
}],
|
||||
});
|
||||
const cached = new docker_build.Image("cached", {
|
||||
push: false,
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
cacheTo: [{
|
||||
local: {
|
||||
dest: "tmp/cache",
|
||||
mode: docker_build.CacheMode.Max,
|
||||
},
|
||||
}],
|
||||
cacheFrom: [{
|
||||
local: {
|
||||
src: "tmp/cache",
|
||||
},
|
||||
}],
|
||||
});
|
||||
const buildArgs = new docker_build.Image("buildArgs", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
location: "./app/Dockerfile.buildArgs",
|
||||
},
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
buildArgs: {
|
||||
SET_ME_TO_TRUE: "true",
|
||||
},
|
||||
});
|
||||
const extraHosts = new docker_build.Image("extraHosts", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
location: "./app/Dockerfile.extraHosts",
|
||||
},
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
addHosts: ["metadata.google.internal:169.254.169.254"],
|
||||
});
|
||||
const sshMount = new docker_build.Image("sshMount", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
location: "./app/Dockerfile.sshMount",
|
||||
},
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
ssh: [{
|
||||
id: "default",
|
||||
}],
|
||||
});
|
||||
const secrets = new docker_build.Image("secrets", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
location: "./app/Dockerfile.secrets",
|
||||
},
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
secrets: {
|
||||
password: "hunter2",
|
||||
},
|
||||
});
|
||||
const labels = new docker_build.Image("labels", {
|
||||
push: false,
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
labels: {
|
||||
description: "This image will get a descriptive label 👍",
|
||||
},
|
||||
});
|
||||
const target = new docker_build.Image("target", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
location: "./app/Dockerfile.target",
|
||||
},
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
target: "build-me",
|
||||
});
|
||||
const namedContexts = new docker_build.Image("namedContexts", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
location: "./app/Dockerfile.namedContexts",
|
||||
},
|
||||
context: {
|
||||
location: "./app",
|
||||
named: {
|
||||
"golang:latest": {
|
||||
location: "docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const remoteContext = new docker_build.Image("remoteContext", {
|
||||
push: false,
|
||||
context: {
|
||||
location: "https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile",
|
||||
},
|
||||
});
|
||||
const remoteContextWithInline = new docker_build.Image("remoteContextWithInline", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
inline: `FROM busybox
|
||||
COPY hello.c ./
|
||||
`,
|
||||
},
|
||||
context: {
|
||||
location: "https://github.com/docker-library/hello-world.git",
|
||||
},
|
||||
});
|
||||
const inline = new docker_build.Image("inline", {
|
||||
push: false,
|
||||
dockerfile: {
|
||||
inline: `FROM alpine
|
||||
RUN echo "This uses an inline Dockerfile! 👍"
|
||||
`,
|
||||
},
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
});
|
||||
const dockerLoad = new docker_build.Image("dockerLoad", {
|
||||
push: false,
|
||||
context: {
|
||||
location: "./app",
|
||||
},
|
||||
exports: [{
|
||||
docker: {
|
||||
tar: true,
|
||||
},
|
||||
}],
|
||||
});
|
||||
export const platforms = multiPlatform.platforms;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "provider-dockerbuild",
|
||||
"name": "provider-docker-build",
|
||||
"devDependencies": {
|
||||
"@types/node": "^18"
|
||||
},
|
||||
@@ -8,4 +8,3 @@
|
||||
"@pulumi/pulumi": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user