2022-09-08 09:26:39 +00:00
|
|
|
ARG BUILDER_IMAGE
|
|
|
|
FROM ${BUILDER_IMAGE} as builder
|
Containerized auto-generation
Run code auto-generation inside a container instead of the host system.
Our auto-generation depends on specific versions of a multitude of tools
(like k8s code-generator, controller-gen, protoc, mockery etc). This
made it really awkward (and error-prone) to run in the host environment,
especially if/when you needed different versions of those tools for
other projects. Making it even more unwieldy, the required versions of
tools were not neatly documented anywhere (except for git commits,
perhaps).
With this patch we have a "fixed environment", as we build a special
auto-generate-builder container which has correct versions of all the
dependencies. Using the container makes auto-generation easy to run
anywhere, independent of the host system, giving reproducibility and
reliability. Also, the patch moves the auto-generation steps out from
the makefile into a separate script, making the makefile cleaner and the
script easier to maintain.
2022-06-14 15:02:23 +00:00
|
|
|
|
|
|
|
# Install tools
|
2024-07-18 12:58:16 +00:00
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
|
|
|
go install github.com/vektra/mockery/v2@v2.42.0 && \
|
2024-03-11 09:51:47 +00:00
|
|
|
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 && \
|
2023-07-27 09:05:23 +00:00
|
|
|
go install golang.org/x/tools/cmd/goimports@v0.11.0 && \
|
Containerized auto-generation
Run code auto-generation inside a container instead of the host system.
Our auto-generation depends on specific versions of a multitude of tools
(like k8s code-generator, controller-gen, protoc, mockery etc). This
made it really awkward (and error-prone) to run in the host environment,
especially if/when you needed different versions of those tools for
other projects. Making it even more unwieldy, the required versions of
tools were not neatly documented anywhere (except for git commits,
perhaps).
With this patch we have a "fixed environment", as we build a special
auto-generate-builder container which has correct versions of all the
dependencies. Using the container makes auto-generation easy to run
anywhere, independent of the host system, giving reproducibility and
reliability. Also, the patch moves the auto-generation steps out from
the makefile into a separate script, making the makefile cleaner and the
script easier to maintain.
2022-06-14 15:02:23 +00:00
|
|
|
go install github.com/golang/protobuf/protoc-gen-go@v1.4.3
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install unzip
|
|
|
|
|
2024-03-11 09:51:47 +00:00
|
|
|
RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip && \
|
|
|
|
unzip protoc-25.3-linux-x86_64.zip -d /usr/local && \
|
|
|
|
rm protoc-25.3-linux-x86_64.zip && \
|
Containerized auto-generation
Run code auto-generation inside a container instead of the host system.
Our auto-generation depends on specific versions of a multitude of tools
(like k8s code-generator, controller-gen, protoc, mockery etc). This
made it really awkward (and error-prone) to run in the host environment,
especially if/when you needed different versions of those tools for
other projects. Making it even more unwieldy, the required versions of
tools were not neatly documented anywhere (except for git commits,
perhaps).
With this patch we have a "fixed environment", as we build a special
auto-generate-builder container which has correct versions of all the
dependencies. Using the container makes auto-generation easy to run
anywhere, independent of the host system, giving reproducibility and
reliability. Also, the patch moves the auto-generation steps out from
the makefile into a separate script, making the makefile cleaner and the
script easier to maintain.
2022-06-14 15:02:23 +00:00
|
|
|
chmod a+x /usr/local/bin/protoc && \
|
|
|
|
find /usr/local -type d | xargs chmod 755 && \
|
|
|
|
find /usr/local -type f | xargs chmod a+r
|
|
|
|
|
|
|
|
|
|
|
|
# Expect to be working with nfd
|
|
|
|
WORKDIR /go/node-feature-discovery
|
2024-03-08 18:44:42 +00:00
|
|
|
|
|
|
|
# We need to set the /go/node-feature-discovery directory as a safe directory.
|
|
|
|
# This allows git commands to run in the container on MacOS systems.
|
|
|
|
RUN git config --file=/.gitconfig --add safe.directory /go/node-feature-discovery
|