-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
61 lines (43 loc) · 1.78 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Dependencies Image
FROM golang:1.22-alpine3.20 AS deps
RUN apk add --no-cache git
WORKDIR /builder
COPY go.mod .
COPY go.sum .
RUN go mod download
# Build Image
FROM deps AS build
COPY . .
# RUN CGO_ENABLED=0 go test -v \
# && go build -o ./out/builder cmd/main.go
RUN go build -o ./out/builder cmd/main.go
# Builder Binary Image
FROM scratch AS builder_binary
COPY --from=build /builder/out/builder /builder
ENTRYPOINT ["/builder"]
# Builder Image Rootless
FROM moby/buildkit:master-rootless AS builder_rootless
COPY --from=builder_binary --chown=user:user /builder /home/user/builder
# TO-DO : Replace with copying from scripts locally
RUN printf '#!/bin/sh\n\
export BUILDKITD_FLAGS=--oci-worker-no-process-sandbox\n\
/home/user/builder $@ | buildctl-daemonless.sh build \
--export-cache type=registry,ref=${EXPORT_REGISTRY},registry.insecure=true \
--import-cache type=registry,ref=${IMPORT_REGISTRY},registry.insecure=true \
--output type=image,name=registry:5000/metacall/builder_output_$1,push=true,registry.insecure=true\n'\
>> /home/user/builder.sh \
&& chmod 700 /home/user/builder.sh \
&& chmod 700 /home/user/builder
# Builder Image
FROM moby/buildkit AS builder_client
COPY --from=builder_binary --chown=root:root /builder /home/builder
RUN apk add --no-cache docker
# TO-DO : Replace with copying from scripts locally
RUN printf '#!/bin/sh\n\
/home/builder $@ | buildctl --addr="docker-container://metacall_builder_buildkit" build \
--export-cache type=registry,ref=${EXPORT_REGISTRY},registry.insecure=true \
--import-cache type=registry,ref=${IMPORT_REGISTRY},registry.insecure=true \
--output type=image,name=registry:5000/metacall/builder_output_$1,push=true,registry.insecure=true\n'\
>> /home/builder.sh \
&& chmod 700 /home/builder.sh \
&& chmod 700 /home/builder