-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.ci-setup-cpp
149 lines (125 loc) · 5.27 KB
/
Dockerfile.ci-setup-cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
## base image
FROM ubuntu:22.04 AS base
ARG extra_libraries
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y -qq && apt-get install --no-install-recommends -y gnupg software-properties-common ca-certificates && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# keys used by apt
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
# Install basic packages available from standard repos
RUN apt-get update -y -qq && \
apt-get install --no-install-recommends -yq \
wget curl pkg-config zip unzip tar git \
gnupg coreutils && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# install CodeCov
WORKDIR /home/codecov
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
ADD https://uploader.codecov.io/latest/alpine/codecov codecov
ADD https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM codecov.SHA256SUM
ADD https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM.sig codecov.SHA256SUM.sig
RUN gpgv codecov.SHA256SUM.sig codecov.SHA256SUM && \
shasum -a 256 -c codecov.SHA256SUM && \
chmod +x codecov
ENV CODECOV "/home/codecov/codecov"
# download setup_cpp https://github.com/aminya/setup-cpp
WORKDIR /
ARG setup_cpp_linux_version="0.24.1"
ARG setup_cpp_linux_download_url="https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux"
# add setup_cpp
ADD ${setup_cpp_linux_download_url} /setup_cpp_linux
RUN chmod +x /setup_cpp_linux
RUN /setup_cpp_linux --compiler llvm \
--gcc true --make true --cmake true --ninja true --ccache true \
--doxygen true --gcovr true --cppcheck true \
--clangtidy true --clangformat true \
--conan true --task true && \
rm -rf /tmp/*
RUN echo 'source /root/.cpprc' >> /root/.bash_profile && \
cp /root/.cpprc /root/.bashrc
# Install more tools from standard repos
RUN apt-get update -y && \
apt-get install --no-install-recommends -y \
${extra_libraries} cmake-extras \
valgrind linux-tools-common linux-tools-generic google-perftools \
python3 python3-pip \
neovim emacs nano && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Install more pip tools
RUN python3 -m pip install --no-cache-dir \
cogapp==3.3.0 \
coverage==7.0.3 \
cmake-format==0.6.13 \
cmakelint==1.4.2
## Cleanup cached apt data we don't need anymore
RUN apt-get autoremove -y && apt-get clean && \
rm -rf /var/lib/apt/lists/*
# thx to https://github.com/lefticus/cpp_starter_project/pull/121
# By default, anything you run in Docker is done as superuser.
# Conan runs some install commands as superuser, and will prepend `sudo` to
# these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables.
ENV CONAN_SYSREQUIRES_SUDO 0
# Some packages request that Conan use the system package manager to install
# a few dependencies. This flag allows Conan to proceed with these installations;
# leaving this flag undefined can cause some installation failures.
ENV CONAN_SYSREQUIRES_MODE enabled
# set default compiler
ENV CC "/root/llvm/bin/clang"
ENV CXX "/root/llvm/bin/clang++"
ENV CMAKE "cmake"
ENV MAKE "/root/ninja/ninja"
# compiler env settings
# e.g. mingw-env, emsdk_env.sh
ARG setup_env_script="/root/.cpprc"
ARG setup_env_script_args=""
ENV SETUP_ENV_SCRIPT $setup_env_script
ENV SETUP_ENV_SCRIPT_ARGS $setup_env_script_args
RUN echo "source \"$SETUP_ENV_SCRIPT $SETUP_ENV_SCRIPT_ARGS\"" >> /root/.bash_profile && \
. $setup_env_script $setup_env_script_args
# setup project env
WORKDIR /home/project
RUN bash -c 'source /root/.cpprc'
COPY ./scripts/docker-entrypoint.setup-cpp.sh /docker-entrypoint.sh
ENTRYPOINT ["/bin/bash", "-c", "/docker-entrypoint.sh"]
CMD ["/bin/bash"]
## ci image
FROM base AS ci-base
# default compiler versions
ARG extra_libraries
# Install packages available from standard repos
RUN apt-get update -y && \
apt-get install --no-install-recommends -y \
wget curl ${extra_libraries} && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# set default compiler
ENV CC "/root/llvm/bin/clang"
ENV CXX "/root/llvm/bin/clang++"
ENV CMAKE "cmake"
ENV MAKE "/root/ninja/ninja"
# install vcpkg
ENV VCPKG_DISABLE_METRICS 1
RUN /setup_cpp_linux --vcpkg true
ENV VCPKG_ROOT "/root/vcpkg"
RUN /root/vcpkg/bootstrap-vcpkg.sh -disableMetrics
ENV VCPKG_TOOLCHAIN_FILE "$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
# build script settings
ENV TARGET "all"
ENV BUILD_TYPE "Release"
ENV CMAKE_GENERATOR "Ninja Multi-Config"
ENV VCPKG_TOOLCHAIN_FILE "/root/vcpkg/scripts/buildsystems/vcpkg.cmake"
ENV TOOLCHAIN_FILE "/root/vcpkg/scripts/buildsystems/vcpkg.cmake"
ENV CMAKE_ARGS ""
# setup project env
ENV PROJECT_DIR /home/project
WORKDIR /home/project
COPY ./scripts/docker-build.setup-cpp.sh ./docker-build.sh
COPY ./scripts/docker-test.setup-cpp.sh ./docker-test.sh
COPY ./scripts/docker-test-coverage.setup-cpp.sh ./docker-test-coverage.sh
COPY ./taskfiles/*.yml /home/taskfiles/
COPY ./taskfiles/TaskfileSetupCpp.yml /home/taskfiles/Taskfile.yml
ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build