-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEarthfile
89 lines (78 loc) · 3.03 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
VERSION 0.8
IMPORT github.com/formancehq/earthly:tags/v0.19.1 AS core
FROM core+base-image
sources:
FROM core+builder-image
WORKDIR /src
WORKDIR /src/components/operator
COPY --dir api internal pkg cmd config .
COPY go.* .
SAVE ARTIFACT /src
controller-gen:
FROM core+builder-image
DO --pass-args core+GO_INSTALL --package=sigs.k8s.io/controller-tools/cmd/[email protected]
generate:
FROM --pass-args +controller-gen
COPY +sources/* /src
WORKDIR /src/components/operator
COPY --dir hack .
RUN --mount=type=cache,id=gomod,target=${GOPATH}/pkg/mod \
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \
controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
SAVE ARTIFACT internal AS LOCAL internal
SAVE ARTIFACT api AS LOCAL api
compile:
FROM core+builder-image
COPY (+sources/*) /src
COPY --pass-args (+generate/*) /src/components/operator
WORKDIR /src/components/operator/cmd
DO --pass-args core+GO_COMPILE
build-image:
FROM core+final-image
ENTRYPOINT ["/usr/bin/operator"]
COPY --pass-args (+compile/main) /usr/bin/operator
ARG REPOSITORY=ghcr.io
ARG tag=latest
DO --pass-args core+SAVE_IMAGE --COMPONENT=operator --TAG=$tag
deploy:
ARG LICENCE_TOKEN=""
ARG LICENCE_ISSUER="http://licence-api.formance.svc.cluster.local:8080/keys"
COPY (+sources/*) /src
LET tag=$(tar cf - /src | sha1sum | awk '{print $1}')
WAIT
BUILD --pass-args +build-image --tag=$tag
BUILD --pass-args ./tools/utils+build-image --tag=$tag
END
FROM --pass-args core+vcluster-deployer-image
COPY --dir helm helm
WORKDIR helm
# When all clients are using the new base CRDS chart, we can uncomment this step
# RUN helm upgrade --install --namespace formance-system --install formance-operator-crds \
# --wait \
# --create-namespace ./base
RUN helm dependency update ./operator
RUN --no-cache helm upgrade --install --namespace formance-system --install formance-operator \
--wait \
--create-namespace \
--set image.tag=$tag \
--set operator.licence.token=$LICENCE_TOKEN \
--set operator.licence.issuer=$LICENCE_ISSUER ./operator \
--set operator.dev=true
WORKDIR /
COPY .earthly .earthly
WORKDIR .earthly
RUN kubectl get versions default || kubectl apply -f k8s-versions.yaml
ARG user
RUN --secret tld helm upgrade --install operator-configuration ./configuration \
--namespace formance-system \
--set gateway.fallback=https://console.$user.$tld
deploy-staging:
FROM --pass-args core+base-argocd
ARG --required TAG
ARG APPLICATION=staging-eu-west-1-hosting-operator
LET SERVER=argocd.internal.formance.cloud
RUN --secret AUTH_TOKEN \
argocd app set $APPLICATION \
--parameter image.tag=$TAG \
--auth-token=$AUTH_TOKEN --server=$SERVER --grpc-web
RUN --secret AUTH_TOKEN argocd --auth-token=$AUTH_TOKEN --server=$SERVER --grpc-web app sync $APPLICATION