mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
Utilize multi-stage build to reduce docker image size
This reduces the size of the Docker image from ca. 1.2GB down to about 750MB. Also, move unit tests from .travis.yml to Dockerfile. Final production image is not able to run unit tests anymore, as sources are missing from there.
This commit is contained in:
parent
1754ae0b65
commit
bff94eb107
2 changed files with 16 additions and 7 deletions
|
@ -5,4 +5,3 @@ services:
|
|||
|
||||
script:
|
||||
- docker build -t quay.io/kubernetes_incubator/node-feature-discovery .
|
||||
- docker run --entrypoint=go quay.io/kubernetes_incubator/node-feature-discovery test
|
||||
|
|
22
Dockerfile
22
Dockerfile
|
@ -1,12 +1,10 @@
|
|||
FROM golang:1.8
|
||||
# Build node feature discovery
|
||||
FROM golang:1.8 as builder
|
||||
|
||||
# Build node feature discovery and set it as entrypoint.
|
||||
ADD . /go/src/github.com/kubernetes-incubator/node-feature-discovery
|
||||
|
||||
WORKDIR /go/src/github.com/kubernetes-incubator/node-feature-discovery
|
||||
|
||||
ENV PATH="/go/src/github.com/kubernetes-incubator/node-feature-discovery/rdt-discovery:${PATH}"
|
||||
|
||||
ENV CMT_CAT_VERSION="v1.2.0"
|
||||
|
||||
ARG NFD_VERSION
|
||||
|
@ -18,7 +16,8 @@ RUN case $(dpkg --print-architecture) in \
|
|||
*) \
|
||||
git clone --depth 1 -b $CMT_CAT_VERSION https://github.com/intel/intel-cmt-cat.git && \
|
||||
make -C intel-cmt-cat/lib install && \
|
||||
make -C rdt-discovery \
|
||||
make -C rdt-discovery && \
|
||||
make -C rdt-discovery install \
|
||||
;; \
|
||||
esac
|
||||
|
||||
|
@ -28,4 +27,15 @@ RUN go install \
|
|||
-ldflags "-s -w -X main.version=$NFD_VERSION" \
|
||||
github.com/kubernetes-incubator/node-feature-discovery
|
||||
|
||||
ENTRYPOINT ["/go/bin/node-feature-discovery"]
|
||||
RUN go test .
|
||||
|
||||
|
||||
# Create production image for running node feature discovery
|
||||
FROM golang:1.8
|
||||
|
||||
COPY --from=builder /usr/local/bin /usr/local/bin
|
||||
COPY --from=builder /usr/local/lib /usr/local/lib
|
||||
RUN ldconfig
|
||||
COPY --from=builder /go/bin/node-feature-discovery /usr/bin/node-feature-discovery
|
||||
|
||||
ENTRYPOINT ["/usr/bin/node-feature-discovery"]
|
||||
|
|
Loading…
Reference in a new issue