fix: lint dockerfiles

* using hadolint
This commit is contained in:
abeimler 2023-01-19 15:02:27 +01:00
parent 088ef837cc
commit 4556f8870e
6 changed files with 40 additions and 47 deletions

View File

@ -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 FROM ubuntu:22.04 AS base
# add setup-cpp # add setup-cpp
RUN apt-get update && apt-get install -y \ RUN apt-get update -qq
npm \ RUN apt-get install -y --no-install-recommends npm
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g setup-cpp RUN npm install -g setup-cpp
# install llvm, cmake, ninja, and ccache # install llvm, cmake, ninja, and ccache

View File

@ -17,23 +17,21 @@ WORKDIR "/"
# run installation # 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 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 CMD ["source", "~/.cpprc"]
RUN pacman -Scc --noconfirm ENTRYPOINT ["/bin/bash"]
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building #### Building
FROM base AS builder FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment ### Running environment
# use a distroless image or ubuntu:22.04 if you wish # 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 the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/

View File

@ -1,11 +1,8 @@
## base image ## base image
FROM fedora as base FROM fedora as base
# nodejs # nodejs and curl for downloading setup-cpp
RUN dnf -y install nodejs RUN dnf -y install nodejs curl
# curl for downloading setup-cpp
RUN dnf -y install curl
# add setup-cpp.js # add setup-cpp.js
COPY "./dist/node12" "/" COPY "./dist/node12" "/"
@ -14,22 +11,21 @@ WORKDIR "/"
# run installation # 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 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 CMD ["source", "~/.cpprc"]
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ] ENTRYPOINT [ "/bin/bash" ]
#### Building #### Building
FROM base AS builder FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment ### Running environment
# use a distroless image or ubuntu:22.04 if you wish # 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 the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/

View File

@ -1,28 +1,29 @@
#### Base Image #### Base Image
FROM ubuntu:22.04 AS base FROM ubuntu:22.04 as base
# install setup-cpp # install setup-cpp
RUN apt-get update && apt-get install -y \ RUN apt-get update -qq
npm \ RUN apt-get install -y --no-install-recommends npm
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g setup-cpp RUN npm install -g setup-cpp
# install llvm, cmake, ninja, and ccache # install llvm, cmake, ninja, and ccache
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
CMD source ~/.cpprc CMD ["source", "~/.cpprc"]
ENTRYPOINT [ "/bin/bash" ] ENTRYPOINT ["/bin/bash"]
#### Building #### Building
FROM base AS builder FROM base as builder
ADD ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment ### Running environment
# use a distroless image or ubuntu:22.04 if you wish # 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 the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/

View File

@ -1,4 +1,4 @@
FROM ubuntu:20.04 AS base FROM ubuntu:20.04 as base
# set time-zone # set time-zone
ENV TZ=Canada/Pacific 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 ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends curl gnupg ca-certificates 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 RUN apt-get install -y --no-install-recommends nodejs
# add setup-cpp.js # add setup-cpp.js
@ -18,19 +18,21 @@ WORKDIR "/"
# run installation # 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 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 CMD ["source", "~/.cpprc"]
ENTRYPOINT [ "/bin/bash" ] ENTRYPOINT ["/bin/bash"]
#### Building #### Building
FROM base AS builder FROM base as builder
ADD ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment ### Running environment
# use a distroless image or ubuntu:20.04 if you wish # 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 the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/

View File

@ -1,8 +1,7 @@
FROM ubuntu:22.04 AS base FROM ubuntu:22.04 AS base
RUN apt-get update && apt-get install -y \ RUN apt-get update -qq
nodejs \ RUN apt-get install -y --no-install-recommends nodejs
&& rm -rf /var/lib/apt/lists/*
# add setup-cpp.js # add setup-cpp.js
COPY "./dist/node12" "/" COPY "./dist/node12" "/"
@ -11,13 +10,10 @@ WORKDIR "/"
# run installation # 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 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 CMD ["source", "~/.cpprc"]
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ] ENTRYPOINT [ "/bin/bash" ]
#### Building #### Building
FROM base AS builder FROM base AS builder
COPY ./dev/cpp_vcpkg_project /home/app COPY ./dev/cpp_vcpkg_project /home/app
@ -25,10 +21,11 @@ WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment ### Running environment
# use a distroless image or ubuntu:22.04 if you wish # 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 the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
ENTRYPOINT ["./my_exe"] ENTRYPOINT ["./my_exe"]s