-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Docker build for FlowAggregator image (#6388)
We have made some improvements to the "main" Antrea Docker images (Agent, Controller) in the past, which can also benefit the FlowAggregator image: * use Docker cache mounts to accelerate builds * improve layer sharing between images by building antctl first * install apt packages first in the final image (before copying binaries over from the intermediate build image); this improves caching and build parallelism. Signed-off-by: Antonin Bas <[email protected]>
- Loading branch information
1 parent
50cfb7a
commit baea218
Showing
2 changed files
with
27 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,23 +17,34 @@ FROM golang:${GO_VERSION} as flow-aggregator-build | |
|
||
WORKDIR /antrea | ||
|
||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=bind,source=go.sum,target=go.sum \ | ||
--mount=type=bind,source=go.mod,target=go.mod \ | ||
go mod download | ||
|
||
COPY . /antrea | ||
|
||
RUN make flow-aggregator antctl-linux | ||
RUN mv bin/antctl-linux bin/antctl | ||
# Build antctl first in order to share an extra layer with other Antrea Docker images. | ||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=cache,target=/root/.cache/go-build/ \ | ||
make antctl-linux && mv bin/antctl-linux bin/antctl | ||
|
||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=cache,target=/root/.cache/go-build/ \ | ||
make flow-aggregator | ||
|
||
# Chose this base image so that a shell is available for users to exec into the container, run antctl and run tools like pprof easily | ||
FROM ubuntu:22.04 | ||
|
||
LABEL maintainer="Antrea <[email protected]>" | ||
LABEL description="The docker image for the flow aggregator" | ||
|
||
COPY --from=flow-aggregator-build /antrea/bin/flow-aggregator / | ||
COPY --from=flow-aggregator-build /antrea/bin/antctl /usr/local/bin/ | ||
|
||
# install ca-certificates | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=flow-aggregator-build /antrea/bin/flow-aggregator / | ||
COPY --from=flow-aggregator-build /antrea/bin/antctl /usr/local/bin/ | ||
|
||
ENTRYPOINT ["/flow-aggregator"] |
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