Pass go build tags from environment.
Can now do something like `make VK_BUILD_TAGS=no_jaeger_exporter build` and jaeger support will not be compiled in. Currently there are build flags to omit every provider and every (the only) supported tracing exporter.
This commit is contained in:
25
Dockerfile
25
Dockerfile
@@ -4,28 +4,23 @@ ENV PATH /go/bin:/usr/local/go/bin:$PATH
|
|||||||
ENV GOPATH /go
|
ENV GOPATH /go
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
ca-certificates
|
ca-certificates \
|
||||||
|
--virtual .build-deps \
|
||||||
COPY . /go/src/github.com/virtual-kubelet/virtual-kubelet
|
|
||||||
|
|
||||||
RUN set -x \
|
|
||||||
&& apk add --no-cache --virtual .build-deps \
|
|
||||||
git \
|
git \
|
||||||
gcc \
|
gcc \
|
||||||
libc-dev \
|
libc-dev \
|
||||||
libgcc \
|
libgcc \
|
||||||
make \
|
make
|
||||||
&& cd /go/src/github.com/virtual-kubelet/virtual-kubelet \
|
|
||||||
&& make build \
|
COPY . /go/src/github.com/virtual-kubelet/virtual-kubelet
|
||||||
&& apk del .build-deps \
|
WORKDIR /go/src/github.com/virtual-kubelet/virtual-kubelet
|
||||||
&& cp bin/virtual-kubelet /usr/bin/virtual-kubelet \
|
ARG BUILD_TAGS="netgo osusergo"
|
||||||
&& rm -rf /go \
|
RUN make VK_BUILD_TAGS="${BUILD_TAGS}" build
|
||||||
&& echo "Build complete."
|
RUN cp bin/virtual-kubelet /usr/bin/virtual-kubelet
|
||||||
|
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
COPY --from=builder /usr/bin/virtual-kubelet /usr/bin/virtual-kubelet
|
COPY --from=builder /usr/bin/virtual-kubelet /usr/bin/virtual-kubelet
|
||||||
COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs
|
COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs
|
||||||
|
|
||||||
ENTRYPOINT [ "/usr/bin/virtual-kubelet" ]
|
ENTRYPOINT [ "/usr/bin/virtual-kubelet" ]
|
||||||
CMD [ "--help" ]
|
CMD [ "--help" ]
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -3,6 +3,7 @@ DOCKER_IMAGE := virtual-kubelet
|
|||||||
exec := $(DOCKER_IMAGE)
|
exec := $(DOCKER_IMAGE)
|
||||||
github_repo := virtual-kubelet/virtual-kubelet
|
github_repo := virtual-kubelet/virtual-kubelet
|
||||||
binary := virtual-kubelet
|
binary := virtual-kubelet
|
||||||
|
build_tags := "netgo osusergo $(VK_BUILD_TAGS)"
|
||||||
|
|
||||||
# comment this line out for quieter things
|
# comment this line out for quieter things
|
||||||
#V := 1 # When V is set, print commands and build progress.
|
#V := 1 # When V is set, print commands and build progress.
|
||||||
@@ -17,12 +18,12 @@ all: test build
|
|||||||
# safebuild builds inside a docker container with no clingons from your $GOPATH
|
# safebuild builds inside a docker container with no clingons from your $GOPATH
|
||||||
safebuild:
|
safebuild:
|
||||||
@echo "Building..."
|
@echo "Building..."
|
||||||
$Q docker build -t $(DOCKER_IMAGE):$(VERSION) .
|
$Q docker build --build-arg BUILD_TAGS=$(tags) -t $(DOCKER_IMAGE):$(VERSION) .
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: authors
|
build: authors
|
||||||
@echo "Building..."
|
@echo "Building..."
|
||||||
$Q CGO_ENABLED=0 go build -a -tags netgo -ldflags '-extldflags "-static"' -o bin/$(binary) $(if $V,-v) $(VERSION_FLAGS) $(IMPORT_PATH)
|
$Q CGO_ENABLED=0 go build -a --tags $(build_tags) -ldflags '-extldflags "-static"' -o bin/$(binary) $(if $V,-v) $(VERSION_FLAGS) $(IMPORT_PATH)
|
||||||
|
|
||||||
.PHONY: tags
|
.PHONY: tags
|
||||||
tags:
|
tags:
|
||||||
@@ -52,7 +53,7 @@ deps: setup
|
|||||||
|
|
||||||
docker:
|
docker:
|
||||||
@echo "Docker Build..."
|
@echo "Docker Build..."
|
||||||
$Q docker build -t $(DOCKER_IMAGE) .
|
$Q docker build --build-arg BUILD_TAGS="$(VK_BUILD_TAGS)" -t $(DOCKER_IMAGE) .
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo "Clean..."
|
@echo "Clean..."
|
||||||
|
|||||||
Reference in New Issue
Block a user