2023-07-16 06:05:41 +08:00
|
|
|
#### Base Image
|
2023-07-16 09:06:32 +08:00
|
|
|
FROM ubuntu:22.04 as setup-cpp-ubuntu
|
2023-07-16 06:05:41 +08:00
|
|
|
|
2023-07-16 09:06:32 +08:00
|
|
|
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
|
2023-07-16 06:05:41 +08:00
|
|
|
|
2023-07-16 09:06:32 +08:00
|
|
|
RUN apt-get update -qq && \
|
|
|
|
# install nodejs
|
|
|
|
apt-get install -y --no-install-recommends nodejs npm && \
|
2023-07-18 01:27:35 +08:00
|
|
|
|
2023-07-16 09:06:32 +08:00
|
|
|
# install the compiler and tools
|
|
|
|
node /usr/lib/setup-cpp/setup-cpp.js \
|
|
|
|
--nala true \
|
|
|
|
--compiler llvm \
|
|
|
|
--cmake true \
|
|
|
|
--ninja true \
|
|
|
|
--task true \
|
|
|
|
--vcpkg true \
|
|
|
|
--python true \
|
|
|
|
--make true \
|
|
|
|
--cppcheck true \
|
|
|
|
--gcovr true \
|
|
|
|
--doxygen true \
|
|
|
|
--ccache true && \
|
|
|
|
# cleanup
|
|
|
|
nala autoremove -y && \
|
|
|
|
nala autopurge -y && \
|
|
|
|
apt-get clean && \
|
|
|
|
nala clean --lists && \
|
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
rm -rf /tmp/*
|
2023-07-16 06:05:41 +08:00
|
|
|
|
|
|
|
ENTRYPOINT ["/bin/bash"]
|
|
|
|
|
2023-07-16 09:06:32 +08:00
|
|
|
#### Building (example)
|
|
|
|
FROM setup-cpp-ubuntu AS builder
|
|
|
|
|
2023-07-16 06:05:41 +08:00
|
|
|
COPY ./dev/cpp_vcpkg_project /home/app
|
|
|
|
WORKDIR /home/app
|
|
|
|
RUN bash -c 'source ~/.cpprc \
|
|
|
|
&& task build'
|
|
|
|
|
2023-07-16 09:06:32 +08:00
|
|
|
#### Running environment
|
|
|
|
# use a fresh image as the runner
|
|
|
|
FROM ubuntu:22.04 as runner
|
2023-07-16 06:05:41 +08:00
|
|
|
|
|
|
|
# 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"]
|
2023-07-20 17:58:51 +08:00
|
|
|
|
|
|
|
#### Cross Building (example)
|
|
|
|
FROM setup-cpp-ubuntu-mingw AS builder-mingw
|
|
|
|
|
|
|
|
COPY ./dev/cpp_vcpkg_project /home/app
|
|
|
|
WORKDIR /home/app
|
|
|
|
RUN bash -c 'source ~/.cpprc \
|
|
|
|
&& task build_cross_mingw'
|