Skip to content

Commit 64346c9

Browse files
committed
examples: create certs bake definition
Signed-off-by: CrazyMax <[email protected]>
1 parent ee8af2d commit 64346c9

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

examples/create-certs/Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM alpine:edge AS gen
4+
RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
5+
RUN apk --update --no-cache add mkcert@testing ca-certificates
6+
WORKDIR /certs
7+
RUN mkdir -p daemon client
8+
ARG SAN=localhost
9+
ARG SAN_CLIENT=client
10+
RUN echo $SAN | tr " " "\n" >SAN
11+
RUN CAROOT=$(pwd) mkcert -cert-file daemon/cert.pem -key-file daemon/key.pem $SAN
12+
RUN CAROOT=$(pwd) mkcert -client -cert-file client/cert.pem -key-file client/key.pem $SAN_CLIENT
13+
RUN cp -f rootCA.pem daemon/ca.pem
14+
RUN cp -f rootCA.pem client/ca.pem
15+
RUN rm -f rootCA.pem rootCA-key.pem
16+
17+
FROM scratch
18+
COPY --from=gen /certs /

examples/create-certs/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Create BuildKit certificates
2+
3+
This [bake definition](docker-bake.hcl) can be used for creating certificates:
4+
5+
```bash
6+
SAN="127.0.0.1" docker buildx bake https://github.com/moby/buildkit.git#master:examples/create-certs
7+
```

examples/create-certs/docker-bake.hcl

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
variable "SAN" {
2+
default = "127.0.0.1"
3+
}
4+
5+
group "default" {
6+
targets = ["certs"]
7+
}
8+
9+
target "certs" {
10+
args = {
11+
SAN = SAN
12+
}
13+
output = ["./.certs"]
14+
}

0 commit comments

Comments
 (0)