mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-17 05:48:21 +00:00
Merge pull request #313 from marquiz/devel/build
Slight rework of building
This commit is contained in:
commit
691f13d2c6
3 changed files with 41 additions and 24 deletions
11
Dockerfile
11
Dockerfile
|
@ -11,13 +11,10 @@ RUN go mod download
|
|||
# Do actual build
|
||||
COPY . /go/node-feature-discovery
|
||||
|
||||
ARG NFD_VERSION
|
||||
ARG VERSION
|
||||
ARG HOSTMOUNT_PREFIX
|
||||
|
||||
RUN go install \
|
||||
-ldflags "-s -w -X sigs.k8s.io/node-feature-discovery/pkg/version.version=$NFD_VERSION -X sigs.k8s.io/node-feature-discovery/source.pathPrefix=$HOSTMOUNT_PREFIX" \
|
||||
./cmd/*
|
||||
RUN install -D -m644 nfd-worker.conf.example /etc/kubernetes/node-feature-discovery/nfd-worker.conf
|
||||
RUN make install VERSION=$VERSION HOSTMOUNT_PREFIX=$HOSTMOUNT_PREFIX
|
||||
|
||||
RUN make test
|
||||
|
||||
|
@ -31,5 +28,5 @@ USER 65534:65534
|
|||
# Use more verbose logging of gRPC
|
||||
ENV GRPC_GO_LOG_SEVERITY_LEVEL="INFO"
|
||||
|
||||
COPY --from=builder /etc/kubernetes/node-feature-discovery /etc/kubernetes/node-feature-discovery
|
||||
COPY --from=builder /go/bin/nfd-* /usr/bin/
|
||||
COPY --from=builder /go/node-feature-discovery/nfd-worker.conf.example /etc/kubernetes/node-feature-discovery/nfd-worker.conf
|
||||
COPY --from=builder /go/bin/* /usr/bin/
|
||||
|
|
26
Makefile
26
Makefile
|
@ -16,18 +16,36 @@ IMAGE_TAG_NAME := $(VERSION)
|
|||
IMAGE_REPO := $(IMAGE_REGISTRY)/$(IMAGE_NAME)
|
||||
IMAGE_TAG := $(IMAGE_REPO):$(IMAGE_TAG_NAME)
|
||||
K8S_NAMESPACE := kube-system
|
||||
HOSTMOUNT_PREFIX := /host-
|
||||
|
||||
# We use different mount prefix for local and container builds.
|
||||
# Take CONTAINER_HOSTMOUNT_PREFIX from HOSTMOUNT_PREFIX if only the latter is specified
|
||||
ifdef HOSTMOUNT_PREFIX
|
||||
CONTAINER_HOSTMOUNT_PREFIX := $(HOSTMOUNT_PREFIX)
|
||||
else
|
||||
CONTAINER_HOSTMOUNT_PREFIX := /host-
|
||||
endif
|
||||
HOSTMOUNT_PREFIX := /
|
||||
|
||||
KUBECONFIG :=
|
||||
E2E_TEST_CONFIG :=
|
||||
|
||||
LDFLAGS = -ldflags "-s -w -X sigs.k8s.io/node-feature-discovery/pkg/version.version=$(VERSION) -X sigs.k8s.io/node-feature-discovery/source.pathPrefix=$(HOSTMOUNT_PREFIX)"
|
||||
|
||||
yaml_templates := $(wildcard *.yaml.template)
|
||||
yaml_instances := $(patsubst %.yaml.template,%.yaml,$(yaml_templates))
|
||||
|
||||
all: image
|
||||
|
||||
build:
|
||||
@mkdir -p bin
|
||||
$(GO_CMD) build -v -o bin $(LDFLAGS) ./cmd/...
|
||||
|
||||
install:
|
||||
$(GO_CMD) install -v $(LDFLAGS) ./cmd/...
|
||||
|
||||
image: yamls
|
||||
$(IMAGE_BUILD_CMD) --build-arg NFD_VERSION=$(VERSION) \
|
||||
--build-arg HOSTMOUNT_PREFIX=$(HOSTMOUNT_PREFIX) \
|
||||
$(IMAGE_BUILD_CMD) --build-arg VERSION=$(VERSION) \
|
||||
--build-arg HOSTMOUNT_PREFIX=$(CONTAINER_HOSTMOUNT_PREFIX) \
|
||||
-t $(IMAGE_TAG) \
|
||||
$(IMAGE_BUILD_EXTRA_OPTS) ./
|
||||
|
||||
|
@ -40,7 +58,7 @@ yamls: $(yaml_instances)
|
|||
-e s',^(\s*)name: node-feature-discovery # NFD namespace,\1name: ${K8S_NAMESPACE},' \
|
||||
-e s',^(\s*)image:.+$$,\1image: ${IMAGE_TAG},' \
|
||||
-e s',^(\s*)namespace:.+$$,\1namespace: ${K8S_NAMESPACE},' \
|
||||
-e s',^(\s*)mountPath: "/host-,\1mountPath: "${HOSTMOUNT_PREFIX},' \
|
||||
-e s',^(\s*)mountPath: "/host-,\1mountPath: "${CONTAINER_HOSTMOUNT_PREFIX},' \
|
||||
$< > $@
|
||||
|
||||
mock:
|
||||
|
|
|
@ -878,7 +878,9 @@ There are several Makefile variables that control the build process and the
|
|||
name of the resulting container image.
|
||||
|
||||
| Variable | Description | Default value
|
||||
| ---------------------- | -------------------------------------------- | ----------- |
|
||||
| -------------------------- | ----------------------------------------------------------------- | ----------- |
|
||||
| HOSTMOUNT_PREFIX | Prefix of system directories for feature discovery (local builds) | /
|
||||
| CONTAINER_HOSTMOUNT_PREFIX | Prefix of system directories for feature discovery (container builds) | <HOSTMOUNT_PREFIX> (*if specified*) /host- (*otherwise*)
|
||||
| IMAGE_BUILD_CMD | Command to build the image | docker build
|
||||
| IMAGE_BUILD_EXTRA_OPTS | Extra options to pass to build command | *empty*
|
||||
| IMAGE_PUSH_CMD | Command to push the image to remote registry | docker push
|
||||
|
|
Loading…
Add table
Reference in a new issue