-
Notifications
You must be signed in to change notification settings - Fork 1
/
Earthfile
96 lines (76 loc) · 2.77 KB
/
Earthfile
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
VERSION 0.8
FROM gcr.io/distroless/static-debian11
ARG --global REGISTRY=europe-north1-docker.pkg.dev/nais-io/nais/images/kafkarator
kubebuilder:
FROM golang:1.23
# Constants
ARG os="linux"
ARG arch="amd64"
ARG kubebuilder_version="2.3.1"
RUN wget -qO - https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${kubebuilder_version}/kubebuilder_${kubebuilder_version}_${os}_${arch}.tar.gz | tar -xz -C /tmp/
SAVE ARTIFACT /tmp/kubebuilder_${kubebuilder_version}_${os}_${arch}/*
SAVE IMAGE --cache-hint
dependencies:
FROM golang:1.23
# Go settings, needs to be ENV to be inherited into build
ENV CGO_ENABLED=0
ENV GOOS="linux"
ENV GOARCH="amd64"
ENV GO111MODULE=on
COPY go.mod go.sum /workspace
WORKDIR /workspace
RUN go mod download
SAVE IMAGE --cache-hint
build:
FROM +dependencies
COPY --dir +kubebuilder/ /usr/local/kubebuilder/
COPY . /workspace
RUN echo ${GOARCH} && make test
RUN go build -installsuffix cgo -o kafkarator cmd/kafkarator/main.go
RUN go build -installsuffix cgo -o canary cmd/canary/main.go
SAVE ARTIFACT kafkarator
SAVE ARTIFACT canary
SAVE IMAGE --cache-hint
docker-kafkarator:
FROM gcr.io/distroless/static-debian11
WORKDIR /
COPY +build/kafkarator /
CMD ["/kafkarator"]
# builtins must be declared
ARG EARTHLY_GIT_SHORT_HASH
ARG kafkarator_image=${REGISTRY}/kafkarator
ARG VERSION=$EARTHLY_GIT_SHORT_HASH
SAVE IMAGE --push ${kafkarator_image}:${VERSION} ${kafkarator_image}:latest
docker-canary:
FROM gcr.io/distroless/static-debian11
WORKDIR /
COPY +build/canary /
CMD ["/canary"]
# builtins must be declared
ARG EARTHLY_GIT_SHORT_HASH
ARG canary_image=${REGISTRY}/canary
ARG VERSION=$EARTHLY_GIT_SHORT_HASH
SAVE IMAGE --push ${canary_image}:${VERSION} ${canary_image}:latest
uv-provider:
FROM ghcr.io/astral-sh/uv:latest
SAVE ARTIFACT /uv
docker-canary-deployer:
FROM ghcr.io/nais/deploy/deploy:latest
WORKDIR /canary/
COPY +uv-provider/uv /usr/local/bin/
COPY canary-deployer/requirements.txt /canary/
RUN apk add python3 && \
/usr/local/bin/uv pip install --system --requirement /canary/requirements.txt
COPY canary-deployer/*.yaml /canary/
COPY canary-deployer/deployer.py /canary/
RUN python3 -c "import deployer" ## Minimal testing that imports actually work
CMD ["python3", "/canary/deployer.py"]
# builtins must be declared
ARG EARTHLY_GIT_SHORT_HASH
ARG canary_deployer_image=${REGISTRY}/canary-deployer
ARG VERSION=$EARTHLY_GIT_SHORT_HASH
SAVE IMAGE --push ${canary_deployer_image}:${VERSION} ${canary_deployer_image}:latest
docker:
BUILD +docker-kafkarator
BUILD +docker-canary
BUILD +docker-canary-deployer