Skip to content

Commit 4556f88

Browse files
committed
fix: lint dockerfiles
* using hadolint
1 parent 088ef83 commit 4556f88

File tree

6 files changed

+40
-47
lines changed

6 files changed

+40
-47
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ Here is an example for using setup-cpp to make a builder image that has the Cpp
162162
FROM ubuntu:22.04 AS base
163163

164164
# add setup-cpp
165-
RUN apt-get update && apt-get install -y \
166-
npm \
167-
&& rm -rf /var/lib/apt/lists/*
165+
RUN apt-get update -qq
166+
RUN apt-get install -y --no-install-recommends npm
168167
RUN npm install -g setup-cpp
169168

170169
# install llvm, cmake, ninja, and ccache

dev/docker/arch_node.dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,21 @@ WORKDIR "/"
1717
# run installation
1818
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
1919

20-
# clean up
21-
RUN pacman -Scc --noconfirm
22-
RUN rm -rf /tmp/*
20+
CMD ["source", "~/.cpprc"]
21+
ENTRYPOINT ["/bin/bash"]
2322

24-
CMD source ~/.cpprc
25-
ENTRYPOINT [ "/bin/bash" ]
2623

2724
#### Building
28-
FROM base AS builder
25+
FROM base as builder
2926
COPY ./dev/cpp_vcpkg_project /home/app
3027
WORKDIR /home/app
3128
RUN bash -c 'source ~/.cpprc \
3229
&& task build'
3330

31+
3432
### Running environment
3533
# use a distroless image or ubuntu:22.04 if you wish
36-
FROM gcr.io/distroless/cc
34+
FROM gcr.io/distroless/cc as runner
3735
# copy the built binaries and their runtime dependencies
3836
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
3937
WORKDIR /home/app/

dev/docker/fedora_node.dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
## base image
22
FROM fedora as base
33

4-
# nodejs
5-
RUN dnf -y install nodejs
6-
7-
# curl for downloading setup-cpp
8-
RUN dnf -y install curl
4+
# nodejs and curl for downloading setup-cpp
5+
RUN dnf -y install nodejs curl
96

107
# add setup-cpp.js
118
COPY "./dist/node12" "/"
@@ -14,22 +11,21 @@ WORKDIR "/"
1411
# run installation
1512
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
1613

17-
# clean up
18-
RUN rm -rf /tmp/*
19-
20-
CMD source ~/.cpprc
14+
CMD ["source", "~/.cpprc"]
2115
ENTRYPOINT [ "/bin/bash" ]
2216

17+
2318
#### Building
24-
FROM base AS builder
19+
FROM base as builder
2520
COPY ./dev/cpp_vcpkg_project /home/app
2621
WORKDIR /home/app
2722
RUN bash -c 'source ~/.cpprc \
2823
&& task build'
2924

25+
3026
### Running environment
3127
# use a distroless image or ubuntu:22.04 if you wish
32-
FROM gcr.io/distroless/cc
28+
FROM gcr.io/distroless/cc as runner
3329
# copy the built binaries and their runtime dependencies
3430
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
3531
WORKDIR /home/app/

dev/docker/ubuntu.dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
#### Base Image
2-
FROM ubuntu:22.04 AS base
2+
FROM ubuntu:22.04 as base
33

44
# install setup-cpp
5-
RUN apt-get update && apt-get install -y \
6-
npm \
7-
&& rm -rf /var/lib/apt/lists/*
5+
RUN apt-get update -qq
6+
RUN apt-get install -y --no-install-recommends npm
87
RUN npm install -g setup-cpp
98

109
# install llvm, cmake, ninja, and ccache
1110
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
1211

13-
CMD source ~/.cpprc
14-
ENTRYPOINT [ "/bin/bash" ]
12+
CMD ["source", "~/.cpprc"]
13+
ENTRYPOINT ["/bin/bash"]
14+
1515

1616
#### Building
17-
FROM base AS builder
18-
ADD ./dev/cpp_vcpkg_project /home/app
17+
FROM base as builder
18+
COPY ./dev/cpp_vcpkg_project /home/app
1919
WORKDIR /home/app
2020
RUN bash -c 'source ~/.cpprc \
2121
&& task build'
2222

23+
2324
### Running environment
2425
# use a distroless image or ubuntu:22.04 if you wish
25-
FROM gcr.io/distroless/cc
26+
FROM gcr.io/distroless/cc as runner
2627
# copy the built binaries and their runtime dependencies
2728
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
2829
WORKDIR /home/app/

dev/docker/ubuntu_20.04_node.dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:20.04 AS base
1+
FROM ubuntu:20.04 as base
22

33
# set time-zone
44
ENV TZ=Canada/Pacific
@@ -8,7 +8,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
88
ENV DEBIAN_FRONTEND=noninteractive
99
RUN apt-get update -qq
1010
RUN apt-get install -y --no-install-recommends curl gnupg ca-certificates
11-
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
11+
RUN ["/bin/bash", "-c", "set -o pipefail && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -"]
1212
RUN apt-get install -y --no-install-recommends nodejs
1313

1414
# add setup-cpp.js
@@ -18,19 +18,21 @@ WORKDIR "/"
1818
# run installation
1919
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
2020

21-
CMD source ~/.cpprc
22-
ENTRYPOINT [ "/bin/bash" ]
21+
CMD ["source", "~/.cpprc"]
22+
ENTRYPOINT ["/bin/bash"]
23+
2324

2425
#### Building
25-
FROM base AS builder
26-
ADD ./dev/cpp_vcpkg_project /home/app
26+
FROM base as builder
27+
COPY ./dev/cpp_vcpkg_project /home/app
2728
WORKDIR /home/app
2829
RUN bash -c 'source ~/.cpprc \
2930
&& task build'
3031

32+
3133
### Running environment
3234
# use a distroless image or ubuntu:20.04 if you wish
33-
FROM gcr.io/distroless/cc
35+
FROM gcr.io/distroless/cc as runner
3436
# copy the built binaries and their runtime dependencies
3537
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
3638
WORKDIR /home/app/

dev/docker/ubuntu_node.dockerfile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
FROM ubuntu:22.04 AS base
22

3-
RUN apt-get update && apt-get install -y \
4-
nodejs \
5-
&& rm -rf /var/lib/apt/lists/*
3+
RUN apt-get update -qq
4+
RUN apt-get install -y --no-install-recommends nodejs
65

76
# add setup-cpp.js
87
COPY "./dist/node12" "/"
@@ -11,24 +10,22 @@ WORKDIR "/"
1110
# run installation
1211
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
1312

14-
# clean up
15-
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
16-
RUN rm -rf /tmp/*
17-
18-
CMD source ~/.cpprc
13+
CMD ["source", "~/.cpprc"]
1914
ENTRYPOINT [ "/bin/bash" ]
2015

16+
2117
#### Building
2218
FROM base AS builder
2319
COPY ./dev/cpp_vcpkg_project /home/app
2420
WORKDIR /home/app
2521
RUN bash -c 'source ~/.cpprc \
2622
&& task build'
2723

24+
2825
### Running environment
2926
# use a distroless image or ubuntu:22.04 if you wish
30-
FROM gcr.io/distroless/cc
27+
FROM gcr.io/distroless/cc as runner
3128
# copy the built binaries and their runtime dependencies
3229
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
3330
WORKDIR /home/app/
34-
ENTRYPOINT ["./my_exe"]
31+
ENTRYPOINT ["./my_exe"]s

0 commit comments

Comments
 (0)