From 088a05395a4b2426705d570f7da35c89d59dfad3 Mon Sep 17 00:00:00 2001 From: Erikson Tung Date: Thu, 19 Aug 2021 13:54:29 -0700 Subject: [PATCH] build: add Dockerfile for controller, build with bottlerocket-sdk Build the binaries with the bottlerocket-sdk. --- Makefile | 16 ++++++++++++++-- controller/Dockerfile | 13 +++++++++++++ .../examples/example_test_agent/Dockerfile | 14 ++++++++++---- 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 controller/Dockerfile diff --git a/Makefile b/Makefile index b7e288996..711740874 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,20 @@ -.PHONY: example-test-agent-container +.PHONY: example-test-agent-container controller-container controller -# Build a container image for daemon and tools. +ARCH=$(shell uname -m) + +containers: controller-container + +# Build the container image for the example test-agent program example-test-agent-container: docker build \ --network=host \ + --build-arg ARCH="$(ARCH)" \ --tag 'example_test_agent' \ -f test-agent/examples/example_test_agent/Dockerfile . + +controller-container: + docker build \ + --network=host \ + --build-arg ARCH="$(ARCH)" \ + --tag 'test-sys-controller' \ + -f controller/Dockerfile . diff --git a/controller/Dockerfile b/controller/Dockerfile new file mode 100644 index 000000000..2356821b2 --- /dev/null +++ b/controller/Dockerfile @@ -0,0 +1,13 @@ +ARG ARCH +FROM public.ecr.aws/bottlerocket/bottlerocket-sdk-${ARCH}:v0.22.0 as build +ARG ARCH +USER root +WORKDIR /src +ADD ./ /src/ +WORKDIR /src/controller +RUN cargo install --locked --verbose --target ${ARCH}-bottlerocket-linux-musl --path . --root ./ + +FROM scratch +COPY --from=build /src/controller/bin/controller ./ + +ENTRYPOINT ["./controller"] diff --git a/test-agent/examples/example_test_agent/Dockerfile b/test-agent/examples/example_test_agent/Dockerfile index 784254830..de97a4176 100644 --- a/test-agent/examples/example_test_agent/Dockerfile +++ b/test-agent/examples/example_test_agent/Dockerfile @@ -1,7 +1,13 @@ -# TODO Use Bottlerocket SDK -FROM rust:1.53.0 +ARG ARCH +FROM public.ecr.aws/bottlerocket/bottlerocket-sdk-${ARCH}:v0.22.0 as build +ARG ARCH +USER root WORKDIR /src ADD ./ /src/ WORKDIR /src/test-agent -RUN cargo install --path . --example example_test_agent --root ./ -ENTRYPOINT ["/src/test-agent/bin/example_test_agent"] +RUN cargo install --locked --verbose --target ${ARCH}-bottlerocket-linux-musl --path . --example example_test_agent --root ./ + +FROM scratch +COPY --from=build /src/test-agent/bin/example_test_agent ./ + +ENTRYPOINT ["./example_test_agent"]