-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The initial implementation. Signed-off-by: Utku Ozdemir <[email protected]>
- Loading branch information
1 parent
2a1d83d
commit 335731d
Showing
33 changed files
with
2,565 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. | ||
# | ||
# Generated on 2024-07-13T08:21:34Z by kres 8c8b007. | ||
# Generated on 2024-06-21T07:15:12Z by kres 4c9f215. | ||
|
||
_out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
# syntax = docker/dockerfile-upstream:1.8.1-labs | ||
# syntax = docker/dockerfile-upstream:1.9.0-labs | ||
|
||
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. | ||
# | ||
# Generated on 2024-07-13T08:21:34Z by kres 8c8b007. | ||
# Generated on 2024-07-16T09:58:51Z by kres ac94478. | ||
|
||
ARG TOOLCHAIN | ||
|
||
# cleaned up specs and compiled versions | ||
FROM scratch AS generate | ||
FROM ghcr.io/siderolabs/talosctl:v1.8.0-alpha.1 AS base-image-omni-cloud-provider-qemu | ||
|
||
FROM ghcr.io/siderolabs/ca-certificates:v1.7.0 AS image-ca-certificates | ||
|
||
FROM ghcr.io/siderolabs/fhs:v1.7.0 AS image-fhs | ||
|
||
# runs markdownlint | ||
FROM docker.io/oven/bun:1.1.17-alpine AS lint-markdown | ||
FROM docker.io/oven/bun:1.1.20-alpine AS lint-markdown | ||
WORKDIR /src | ||
RUN bun i [email protected] [email protected] | ||
COPY .markdownlint.json . | ||
COPY ./README.md ./README.md | ||
RUN bunx markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules node_modules/sentences-per-line/index.js . | ||
|
||
# collects proto specs | ||
FROM scratch AS proto-specs | ||
ADD api/specs/specs.proto /api/specs/ | ||
|
||
# base toolchain image | ||
FROM --platform=${BUILDPLATFORM} ${TOOLCHAIN} AS toolchain | ||
RUN apk --update --no-cache add bash curl build-base protoc protobuf-dev | ||
|
@@ -35,6 +38,21 @@ ENV GOTOOLCHAIN=${GOTOOLCHAIN} | |
ARG GOEXPERIMENT | ||
ENV GOEXPERIMENT=${GOEXPERIMENT} | ||
ENV GOPATH=/go | ||
ARG GOIMPORTS_VERSION | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/tools/cmd/goimports@v${GOIMPORTS_VERSION} | ||
RUN mv /go/bin/goimports /bin | ||
ARG PROTOBUF_GO_VERSION | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install google.golang.org/protobuf/cmd/protoc-gen-go@v${PROTOBUF_GO_VERSION} | ||
RUN mv /go/bin/protoc-gen-go /bin | ||
ARG GRPC_GO_VERSION | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${GRPC_GO_VERSION} | ||
RUN mv /go/bin/protoc-gen-go-grpc /bin | ||
ARG GRPC_GATEWAY_VERSION | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION} | ||
RUN mv /go/bin/protoc-gen-grpc-gateway /bin | ||
ARG VTPROTOBUF_VERSION | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@v${VTPROTOBUF_VERSION} | ||
RUN mv /go/bin/protoc-gen-go-vtproto /bin | ||
ARG DEEPCOPY_VERSION | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \ | ||
&& mv /go/bin/deep-copy /bin/deep-copy | ||
|
@@ -55,9 +73,27 @@ COPY go.sum go.sum | |
RUN cd . | ||
RUN --mount=type=cache,target=/go/pkg go mod download | ||
RUN --mount=type=cache,target=/go/pkg go mod verify | ||
COPY ./api ./api | ||
COPY ./cmd ./cmd | ||
COPY ./internal ./internal | ||
RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null | ||
|
||
FROM tools AS embed-generate | ||
ARG SHA | ||
ARG TAG | ||
WORKDIR /src | ||
RUN mkdir -p internal/version/data && \ | ||
echo -n ${SHA} > internal/version/data/sha && \ | ||
echo -n ${TAG} > internal/version/data/tag | ||
|
||
# runs protobuf compiler | ||
FROM tools AS proto-compile | ||
COPY --from=proto-specs / / | ||
RUN protoc -I/api --go_out=paths=source_relative:/api --go-grpc_out=paths=source_relative:/api --go-vtproto_out=paths=source_relative:/api --go-vtproto_opt=features=marshal+unmarshal+size+equal+clone /api/specs/specs.proto | ||
RUN rm /api/specs/specs.proto | ||
RUN goimports -w -local github.com/siderolabs/omni-cloud-provider-qemu /api | ||
RUN gofumpt -w /api | ||
|
||
# runs gofumpt | ||
FROM base AS lint-gofumpt | ||
RUN FILES="$(gofumpt -l .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'gofumpt -w .':\n${FILES}"; exit 1) | ||
|
@@ -75,50 +111,69 @@ FROM base AS lint-govulncheck | |
WORKDIR /src | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg govulncheck ./... | ||
|
||
# runs unit-tests with race detector | ||
FROM base AS unit-tests-race | ||
WORKDIR /src | ||
ARG TESTPKGS | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp CGO_ENABLED=1 go test -v -race -count 1 ${TESTPKGS} | ||
|
||
# runs unit-tests | ||
FROM base AS unit-tests-run | ||
WORKDIR /src | ||
ARG TESTPKGS | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS} | ||
|
||
FROM embed-generate AS embed-abbrev-generate | ||
WORKDIR /src | ||
ARG ABBREV_TAG | ||
RUN echo -n 'undefined' > internal/version/data/sha && \ | ||
echo -n ${ABBREV_TAG} > internal/version/data/tag | ||
|
||
FROM scratch AS unit-tests | ||
COPY --from=unit-tests-run /src/coverage.txt /coverage-unit-tests.txt | ||
|
||
# cleaned up specs and compiled versions | ||
FROM scratch AS generate | ||
COPY --from=proto-compile /api/ /api/ | ||
COPY --from=embed-abbrev-generate /src/internal/version internal/version | ||
|
||
# builds omni-cloud-provider-qemu-linux-amd64 | ||
FROM base AS omni-cloud-provider-qemu-linux-amd64-build | ||
COPY --from=generate / / | ||
COPY --from=embed-generate / / | ||
WORKDIR /src/cmd/omni-cloud-provider-qemu | ||
ARG GO_BUILDFLAGS | ||
ARG GO_LDFLAGS | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=amd64 GOOS=linux go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS}" -o /omni-cloud-provider-qemu-linux-amd64 | ||
ARG VERSION_PKG="internal/version" | ||
ARG SHA | ||
ARG TAG | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=amd64 GOOS=linux go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS} -X ${VERSION_PKG}.Name=omni-cloud-provider-qemu -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /omni-cloud-provider-qemu-linux-amd64 | ||
|
||
# builds omni-cloud-provider-qemu-linux-arm64 | ||
FROM base AS omni-cloud-provider-qemu-linux-arm64-build | ||
COPY --from=generate / / | ||
COPY --from=embed-generate / / | ||
WORKDIR /src/cmd/omni-cloud-provider-qemu | ||
ARG GO_BUILDFLAGS | ||
ARG GO_LDFLAGS | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=arm64 GOOS=linux go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS}" -o /omni-cloud-provider-qemu-linux-arm64 | ||
|
||
# runs unit-tests with race detector | ||
FROM base AS unit-tests-race | ||
WORKDIR /src | ||
ARG TESTPKGS | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp CGO_ENABLED=1 go test -v -race -count 1 ${TESTPKGS} | ||
|
||
# runs unit-tests | ||
FROM base AS unit-tests-run | ||
WORKDIR /src | ||
ARG TESTPKGS | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS} | ||
ARG VERSION_PKG="internal/version" | ||
ARG SHA | ||
ARG TAG | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=arm64 GOOS=linux go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS} -X ${VERSION_PKG}.Name=omni-cloud-provider-qemu -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /omni-cloud-provider-qemu-linux-arm64 | ||
|
||
FROM scratch AS omni-cloud-provider-qemu-linux-amd64 | ||
COPY --from=omni-cloud-provider-qemu-linux-amd64-build /omni-cloud-provider-qemu-linux-amd64 /omni-cloud-provider-qemu-linux-amd64 | ||
|
||
FROM scratch AS omni-cloud-provider-qemu-linux-arm64 | ||
COPY --from=omni-cloud-provider-qemu-linux-arm64-build /omni-cloud-provider-qemu-linux-arm64 /omni-cloud-provider-qemu-linux-arm64 | ||
|
||
FROM scratch AS unit-tests | ||
COPY --from=unit-tests-run /src/coverage.txt /coverage-unit-tests.txt | ||
|
||
FROM omni-cloud-provider-qemu-linux-${TARGETARCH} AS omni-cloud-provider-qemu | ||
|
||
FROM scratch AS omni-cloud-provider-qemu-all | ||
COPY --from=omni-cloud-provider-qemu-linux-amd64 / / | ||
COPY --from=omni-cloud-provider-qemu-linux-arm64 / / | ||
|
||
FROM scratch AS image-omni-cloud-provider-qemu | ||
FROM base-image-omni-cloud-provider-qemu AS image-omni-cloud-provider-qemu | ||
ARG TARGETARCH | ||
COPY --from=omni-cloud-provider-qemu omni-cloud-provider-qemu-linux-${TARGETARCH} /omni-cloud-provider-qemu | ||
COPY --from=image-fhs / / | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.