Add HCL Examples & Docs (#852)
Fixes https://github.com/pulumi/pulumi-docker-build/issues/844
This commit is contained in:
2
examples/hcl/.dockerignore
Normal file
2
examples/hcl/.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
||||
command-output
|
||||
tmp
|
||||
10
examples/hcl/Pulumi.yaml
Normal file
10
examples/hcl/Pulumi.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
name: provider-docker-build
|
||||
runtime: hcl
|
||||
config:
|
||||
dockerHubPassword:
|
||||
type: string
|
||||
secret: true
|
||||
plugins:
|
||||
providers:
|
||||
- name: docker-build
|
||||
path: ../../bin
|
||||
2
examples/hcl/app/Dockerfile
Normal file
2
examples/hcl/app/Dockerfile
Normal file
@@ -0,0 +1,2 @@
|
||||
FROM alpine
|
||||
RUN echo 👍
|
||||
5
examples/hcl/app/Dockerfile.buildArgs
Normal file
5
examples/hcl/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/hcl/app/Dockerfile.emptyContext
Normal file
2
examples/hcl/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/hcl/app/Dockerfile.extraHosts
Normal file
3
examples/hcl/app/Dockerfile.extraHosts
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM bash AS base
|
||||
|
||||
RUN getent hosts metadata.google.internal
|
||||
7
examples/hcl/app/Dockerfile.multiPlatform
Normal file
7
examples/hcl/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/hcl/app/Dockerfile.namedContexts
Normal file
5
examples/hcl/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/hcl/app/Dockerfile.secrets
Normal file
4
examples/hcl/app/Dockerfile.secrets
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM alpine
|
||||
|
||||
RUN --mount=type=secret,id=password [ "$(cat /run/secrets/password)" = "hunter2" ]
|
||||
|
||||
5
examples/hcl/app/Dockerfile.sshMount
Normal file
5
examples/hcl/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/hcl/app/Dockerfile.target
Normal file
8
examples/hcl/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" ]
|
||||
171
examples/hcl/program.hcl
Normal file
171
examples/hcl/program.hcl
Normal file
@@ -0,0 +1,171 @@
|
||||
pulumi {
|
||||
required_providers {
|
||||
docker-build = {
|
||||
source = "pulumi/docker-build"
|
||||
version = "0.1.0-alpha.0+dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "docker-build_image" "multiPlatform" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
location = "./app/Dockerfile.multiPlatform"
|
||||
}
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
platforms = ["plan9/amd64", "plan9/386"]
|
||||
}
|
||||
resource "docker-build_image" "registryPush" {
|
||||
push = false
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
tags = ["docker.io/pulumibot/buildkit-e2e:example"]
|
||||
exports {
|
||||
registry = {
|
||||
oci_media_types = true
|
||||
push = false
|
||||
}
|
||||
}
|
||||
registries {
|
||||
address = "docker.io"
|
||||
username = "pulumibot"
|
||||
password = var.dockerHubPassword
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "cached" {
|
||||
push = false
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
cache_to {
|
||||
local = {
|
||||
dest = "tmp/cache"
|
||||
mode = "max"
|
||||
}
|
||||
}
|
||||
cache_from {
|
||||
local = {
|
||||
src = "tmp/cache"
|
||||
}
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "buildArgs" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
location = "./app/Dockerfile.buildArgs"
|
||||
}
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
build_args = {
|
||||
"SET_ME_TO_TRUE" = "true"
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "extraHosts" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
location = "./app/Dockerfile.extraHosts"
|
||||
}
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
add_hosts = ["metadata.google.internal:169.254.169.254"]
|
||||
}
|
||||
resource "docker-build_image" "sshMount" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
location = "./app/Dockerfile.sshMount"
|
||||
}
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
ssh {
|
||||
id = "default"
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "secrets" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
location = "./app/Dockerfile.secrets"
|
||||
}
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
secrets = {
|
||||
"password" = "hunter2"
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "labels" {
|
||||
push = false
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
labels = {
|
||||
"description" = "This image will get a descriptive label 👍"
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "target" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
location = "./app/Dockerfile.target"
|
||||
}
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
target = "build-me"
|
||||
}
|
||||
resource "docker-build_image" "namedContexts" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
location = "./app/Dockerfile.namedContexts"
|
||||
}
|
||||
context = {
|
||||
location = "./app"
|
||||
named = {
|
||||
"golang:latest" = {
|
||||
location = "docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "remoteContext" {
|
||||
push = false
|
||||
context = {
|
||||
location = "https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile"
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "remoteContextWithInline" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
inline = "FROM busybox\nCOPY hello.c ./\n"
|
||||
}
|
||||
context = {
|
||||
location = "https://github.com/docker-library/hello-world.git"
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "inline" {
|
||||
push = false
|
||||
dockerfile = {
|
||||
inline = "FROM alpine\nRUN echo \"This uses an inline Dockerfile! 👍\"\n"
|
||||
}
|
||||
}
|
||||
resource "docker-build_image" "dockerLoad" {
|
||||
push = false
|
||||
context = {
|
||||
location = "./app"
|
||||
}
|
||||
exports {
|
||||
docker = {
|
||||
tar = true
|
||||
}
|
||||
}
|
||||
}
|
||||
variable "dockerHubPassword" {
|
||||
type = string
|
||||
}
|
||||
output "platforms" {
|
||||
value = docker-build_image.multiPlatform.platforms
|
||||
}
|
||||
Reference in New Issue
Block a user