diff --git a/images/.utils/Earthfile b/images/.utils/Earthfile index d8de15e28ae8cb12ca01172f3e18051e327a76da..df6582d3d0132f2425ead17bda488e135f63bc87 100644 --- a/images/.utils/Earthfile +++ b/images/.utils/Earthfile @@ -5,4 +5,16 @@ SCAN: FROM ../mirror+trivy WITH DOCKER --load image=+container RUN trivy image image:latest - END \ No newline at end of file + END + +LABEL: + COMMAND + ARG image + ARG EARTHLY_GIT_CO_AUTHORS + ARG EARTHLY_GIT_BRANCH + LABEL org.opencontainers.image.title="${image}" + LABEL org.opencontainers.image.source="https://git.shivering-isles.com/shivering-isles/infrastructure-gitops/-/tree/main/images/${image}" + LABEL org.opencontainers.image.url="https://git.shivering-isles.com/shivering-isles/infrastructure-gitops/-/tree/main/images/${image}" + LABEL org.opencontainers.image.version="${EARTHLY_GIT_BRANCH}" + LABEL org.opencontainers.image.description="Container for ${image} by ${author}" + LABEL org.opencontainers.image.authors="${EARTHLY_GIT_CO_AUTHORS}" \ No newline at end of file diff --git a/images/opentf/Earthfile b/images/opentf/Earthfile index 2280bcaa17fa9da91bffd0172dd8a769c8cef052..08de6736c45049687748a8aca6be978c1254c9a9 100644 --- a/images/opentf/Earthfile +++ b/images/opentf/Earthfile @@ -1,19 +1,31 @@ VERSION 0.7 +src: + FROM ../mirror+golang + ARG branch=main + WORKDIR /go-workdir + GIT CLONE --branch=${branch} https://github.com/opentofu/opentofu.git ./ + SAVE ARTIFACT ./ ./src + build: FROM ../mirror+golang WORKDIR /go-workdir - GIT CLONE --branch=v1.6.0-alpha2 https://github.com/opentofu/opentofu.git ./ + COPY +src/src/go.mod ./ + COPY +src/src/go.sum ./ ENV CGO_ENABLED=0 + RUN go mod download && go mod verify + COPY +src/src/ ./ RUN go build -ldflags "-s -w" -mod=readonly -trimpath ./cmd/tofu SAVE ARTIFACT ./tofu ./tofu container-internal: FROM ../mirror+distroless-static + ARG branch=main COPY +build/tofu /usr/local/bin/tofu COPY +build/tofu /usr/local/bin/opentofu COPY +build/tofu /usr/local/bin/opentf ENTRYPOINT ["/usr/local/bin/tofu"] + DO ../.utils/+LABEL --image=opentf --version=${branch} container: FROM ../mirror+golang @@ -22,10 +34,10 @@ container: ARG tag=$(awk -F'=' '$1 == "release" {print $2}' .release) ARG latest=false IF [ $latest = "true" ] - FROM +container-internal + FROM +container-internal --branch=v${tag} SAVE IMAGE --push ${registry}:latest ELSE - FROM +container-internal + FROM +container-internal --branch=v${tag} LABEL "quay.expires-after"="12w" END SAVE IMAGE --push ${registry}:${tag}