diff --git a/README.md b/README.md index c07397f1..fa456a5d 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,8 @@ jobs: Here is an example for using setup_cpp to make a builder image that has the Cpp tools you need. ```dockerfile -FROM ubuntu:devel +#### Base Image +FROM ubuntu:devel AS base # add setup_cpp WORKDIR "/" @@ -189,12 +190,25 @@ RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0. RUN chmod +x ./setup_cpp_linux # install llvm, cmake, ninja, and ccache -RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true - -# activate cpp environment variables -RUN source ~/.cpprc +RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true +CMD source ~/.cpprc ENTRYPOINT [ "/bin/bash" ] + +#### Building +FROM base AS builder +ADD ./dev/cpp_vcpkg_project /home/app +WORKDIR /home/app +RUN bash -c 'source ~/.cpprc \ + && make build' + +### Running environment +# use a distroless image or ubuntu:devel if you wish +FROM gcr.io/distroless/cc +# copy the built binaries and their runtime dependencies +COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ +WORKDIR /home/app/ +ENTRYPOINT ["./my_exe"] ``` See [this folder](https://github.com/aminya/setup-cpp/tree/master/dev/docker), for some dockerfile examples. diff --git a/dev/docker/ubuntu.dockerfile b/dev/docker/ubuntu.dockerfile index cc091a9a..e1e9ed09 100644 --- a/dev/docker/ubuntu.dockerfile +++ b/dev/docker/ubuntu.dockerfile @@ -22,6 +22,7 @@ RUN bash -c 'source ~/.cpprc \ && make build' ### Running environment +# use a distroless image or ubuntu:devel if you wish FROM gcr.io/distroless/cc # copy the built binaries and their runtime dependencies COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ diff --git a/dev/docker/ubuntu_node.dockerfile b/dev/docker/ubuntu_node.dockerfile index fbfd84d8..1bbd70be 100644 --- a/dev/docker/ubuntu_node.dockerfile +++ b/dev/docker/ubuntu_node.dockerfile @@ -21,6 +21,7 @@ RUN bash -c 'source ~/.cpprc \ && make build' ### Running environment +# use a distroless image or ubuntu:devel if you wish FROM gcr.io/distroless/cc # copy the built binaries and their runtime dependencies COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ diff --git a/dev/docker/ubuntu_stable_node.dockerfile b/dev/docker/ubuntu_stable_node.dockerfile index 21d1910c..b4120ac7 100644 --- a/dev/docker/ubuntu_stable_node.dockerfile +++ b/dev/docker/ubuntu_stable_node.dockerfile @@ -29,6 +29,7 @@ RUN bash -c 'source ~/.cpprc \ && make build' ### Running environment +# use a distroless image or ubuntu:20.04 if you wish FROM gcr.io/distroless/cc # copy the built binaries and their runtime dependencies COPY --from=builder /home/app/build/my_exe/Release/ /home/app/