diff --git a/README.md b/README.md index c06ab6dc..04d73db4 100644 --- a/README.md +++ b/README.md @@ -162,9 +162,8 @@ Here is an example for using setup-cpp to make a builder image that has the Cpp FROM ubuntu:22.04 AS base # add setup-cpp -RUN apt-get update && apt-get install -y \ - npm \ - && rm -rf /var/lib/apt/lists/* +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends npm RUN npm install -g setup-cpp # install llvm, cmake, ninja, and ccache diff --git a/dev/docker/arch_node.dockerfile b/dev/docker/arch_node.dockerfile index 4be8825a..8634efdf 100644 --- a/dev/docker/arch_node.dockerfile +++ b/dev/docker/arch_node.dockerfile @@ -17,23 +17,21 @@ WORKDIR "/" # run installation RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true -# clean up -RUN pacman -Scc --noconfirm -RUN rm -rf /tmp/* +CMD ["source", "~/.cpprc"] +ENTRYPOINT ["/bin/bash"] -CMD source ~/.cpprc -ENTRYPOINT [ "/bin/bash" ] #### Building -FROM base AS builder +FROM base as builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app RUN bash -c 'source ~/.cpprc \ && task build' + ### Running environment # use a distroless image or ubuntu:22.04 if you wish -FROM gcr.io/distroless/cc +FROM gcr.io/distroless/cc as runner # copy the built binaries and their runtime dependencies COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ WORKDIR /home/app/ diff --git a/dev/docker/fedora_node.dockerfile b/dev/docker/fedora_node.dockerfile index 8965cf56..9bbe2e57 100644 --- a/dev/docker/fedora_node.dockerfile +++ b/dev/docker/fedora_node.dockerfile @@ -1,11 +1,8 @@ ## base image FROM fedora as base -# nodejs -RUN dnf -y install nodejs - -# curl for downloading setup-cpp -RUN dnf -y install curl +# nodejs and curl for downloading setup-cpp +RUN dnf -y install nodejs curl # add setup-cpp.js COPY "./dist/node12" "/" @@ -14,22 +11,21 @@ WORKDIR "/" # run installation RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true -# clean up -RUN rm -rf /tmp/* - -CMD source ~/.cpprc +CMD ["source", "~/.cpprc"] ENTRYPOINT [ "/bin/bash" ] + #### Building -FROM base AS builder +FROM base as builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app RUN bash -c 'source ~/.cpprc \ && task build' + ### Running environment # use a distroless image or ubuntu:22.04 if you wish -FROM gcr.io/distroless/cc +FROM gcr.io/distroless/cc as runner # copy the built binaries and their runtime dependencies COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ WORKDIR /home/app/ diff --git a/dev/docker/ubuntu.dockerfile b/dev/docker/ubuntu.dockerfile index e25365f1..7ddb1d7f 100644 --- a/dev/docker/ubuntu.dockerfile +++ b/dev/docker/ubuntu.dockerfile @@ -1,28 +1,29 @@ #### Base Image -FROM ubuntu:22.04 AS base +FROM ubuntu:22.04 as base # install setup-cpp -RUN apt-get update && apt-get install -y \ - npm \ - && rm -rf /var/lib/apt/lists/* +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends npm RUN npm install -g setup-cpp # install llvm, cmake, ninja, and ccache RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true -CMD source ~/.cpprc -ENTRYPOINT [ "/bin/bash" ] +CMD ["source", "~/.cpprc"] +ENTRYPOINT ["/bin/bash"] + #### Building -FROM base AS builder -ADD ./dev/cpp_vcpkg_project /home/app +FROM base as builder +COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app RUN bash -c 'source ~/.cpprc \ && task build' + ### Running environment # use a distroless image or ubuntu:22.04 if you wish -FROM gcr.io/distroless/cc +FROM gcr.io/distroless/cc as runner # copy the built binaries and their runtime dependencies COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ WORKDIR /home/app/ diff --git a/dev/docker/ubuntu_20.04_node.dockerfile b/dev/docker/ubuntu_20.04_node.dockerfile index df959338..10a8494c 100644 --- a/dev/docker/ubuntu_20.04_node.dockerfile +++ b/dev/docker/ubuntu_20.04_node.dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 AS base +FROM ubuntu:20.04 as base # set time-zone ENV TZ=Canada/Pacific @@ -8,7 +8,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -qq RUN apt-get install -y --no-install-recommends curl gnupg ca-certificates -RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - +RUN ["/bin/bash", "-c", "set -o pipefail && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -"] RUN apt-get install -y --no-install-recommends nodejs # add setup-cpp.js @@ -18,19 +18,21 @@ WORKDIR "/" # run installation RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true -CMD source ~/.cpprc -ENTRYPOINT [ "/bin/bash" ] +CMD ["source", "~/.cpprc"] +ENTRYPOINT ["/bin/bash"] + #### Building -FROM base AS builder -ADD ./dev/cpp_vcpkg_project /home/app +FROM base as builder +COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app RUN bash -c 'source ~/.cpprc \ && task build' + ### Running environment # use a distroless image or ubuntu:20.04 if you wish -FROM gcr.io/distroless/cc +FROM gcr.io/distroless/cc as runner # copy the built binaries and their runtime dependencies COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ WORKDIR /home/app/ diff --git a/dev/docker/ubuntu_node.dockerfile b/dev/docker/ubuntu_node.dockerfile index 3a851aa1..78aedf64 100644 --- a/dev/docker/ubuntu_node.dockerfile +++ b/dev/docker/ubuntu_node.dockerfile @@ -1,8 +1,7 @@ FROM ubuntu:22.04 AS base -RUN apt-get update && apt-get install -y \ - nodejs \ - && rm -rf /var/lib/apt/lists/* +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends nodejs # add setup-cpp.js COPY "./dist/node12" "/" @@ -11,13 +10,10 @@ WORKDIR "/" # run installation RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true -# clean up -RUN apt-get clean && rm -rf /var/lib/apt/lists/* -RUN rm -rf /tmp/* - -CMD source ~/.cpprc +CMD ["source", "~/.cpprc"] ENTRYPOINT [ "/bin/bash" ] + #### Building FROM base AS builder COPY ./dev/cpp_vcpkg_project /home/app @@ -25,10 +21,11 @@ WORKDIR /home/app RUN bash -c 'source ~/.cpprc \ && task build' + ### Running environment # use a distroless image or ubuntu:22.04 if you wish -FROM gcr.io/distroless/cc +FROM gcr.io/distroless/cc as runner # 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"] +ENTRYPOINT ["./my_exe"]s