11# ====================== BASE IMAGE ======================
2- ARG UBUNTU_VERSION
2+ ARG UBUNTU_VERSION=jammy
33FROM ubuntu:${UBUNTU_VERSION} AS base
44
5- # Use Bash as the default shell for RUN commands and as the entrypoint .
5+ # Use Bash as the default shell for RUN commands.
66SHELL ["/bin/bash" , "-c" ]
7- ENTRYPOINT ["/bin/bash" ]
7+
8+ # Associate the image with the repository.
9+ ARG GITHUB_REPO=XRPLF/ci
10+ LABEL org.opencontainers.image.source=https://github.com/${GITHUB_REPO}
811
912# Ensure any packages installed directly or indirectly via dpkg do not require
1013# manual interaction.
1114ARG DEBIAN_FRONTEND=noninteractive
12- RUN <<EOF
13- set -ex
14- ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
15- apt update
16- apt upgrade -y
17- apt install -y tzdata
18- dpkg-reconfigure --frontend noninteractive tzdata
19- EOF
15+ RUN apt update && apt upgrade -y
16+ RUN set -ex ;\
17+ ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime ;\
18+ apt install -y tzdata ;\
19+ dpkg-reconfigure --frontend noninteractive tzdata
2020
21- # Install tools that are shared by all stages. Run `apt update` again before
22- # installing the packages to ensure the package lists are up-to-date, which is
23- # especially important when the image is built from a cached layer.
21+ # Install tools that are shared by all stages.
2422RUN <<EOF
25- pkgs=()
26- pkgs+=(bison) # Required build tool.
27- pkgs+=(ca-certificates) # Enable TLS verification for HTTPS connections by providing trusted root certificates.
28- pkgs+=(cmake) # Required build tool.
29- pkgs+=(curl) # Dependency for tools requiring downloading data.
30- pkgs+=(flex) # Required build tool.
31- pkgs+=(git) # Required build tool.
32- pkgs+=(gpg) # Dependency for tools requiring signing or encrypting/decrypting.
33- pkgs+=(jq) # Pretty printing.
34- pkgs+=(libc6-dev) # Required build tool.
35- pkgs+=(ninja-build) # Required build tool.
36- pkgs+=(pipx) # Package manager for Python applications.
37- pkgs+=(wget) # Required build tool.
38- apt update
39- apt install -y "${pkgs[@]}"
23+ pkgs=()
24+ pkgs+=(build-essential) # Required build tools.
25+ pkgs+=(ca-certificates) # Enable TLS verification for HTTPS connections by providing trusted root certificates.
26+ pkgs+=(cmake) # Required build tool.
27+ pkgs+=(curl) # Dependency for tools requiring downloading data.
28+ pkgs+=(file) # Required packaging tool.
29+ pkgs+=(git) # Required build tool.
30+ pkgs+=(gpg) # Dependency for tools requiring signing or encrypting/decrypting.
31+ pkgs+=(jq) # Pretty printing.
32+ pkgs+=(ninja-build) # Required build tool.
33+ pkgs+=(pipx) # Package manager for Python applications.
34+ apt install -y "${pkgs[@]}"
4035EOF
4136
42- # Install Conan.
43- ARG CONAN_VERSION
44- RUN PIPX_HOME=/opt/pipx \
45- PIPX_BIN_DIR=/usr/bin \
46- PIPX_MAN_DIR=/usr/share/man \
47- pipx install conan==${CONAN_VERSION}
37+ # Install Conan && gcovr
38+ ARG CONAN_VERSION=2.18.0
39+ ARG GCOVR_VERSION=8.2
40+ ENV PIPX_HOME=/opt/pipx \
41+ PIPX_BIN_DIR=/usr/local/bin \
42+ PIPX_MAN_DIR=/usr/share/man
43+ RUN pipx install conan==${CONAN_VERSION} && \
44+ pipx install gcovr==${GCOVR_VERSION}
4845
4946# Create the user to switch to, once all packages have been installed.
50- ARG NONROOT_USER
47+ ARG NONROOT_USER=ci
5148RUN useradd -ms /bin/bash ${NONROOT_USER}
5249
5350# ====================== GCC IMAGE ======================
5451FROM base AS gcc
5552
5653# Install GCC.
57- ARG GCC_VERSION
54+ ARG GCC_VERSION=12
5855RUN apt install -y gcc-${GCC_VERSION} g++-${GCC_VERSION}
5956ENV CC=/usr/bin/gcc-${GCC_VERSION}
60- ENV CXX=/usr/bin/g++ -${GCC_VERSION}
57+ ENV CXX=/usr/bin/gcc -${GCC_VERSION}
6158
6259# Clean up unnecessary files to reduce image size.
6360RUN rm -rf /var/lib/apt/lists/* && apt clean
@@ -68,23 +65,12 @@ WORKDIR /home/${NONROOT_USER}
6865
6966# Create a default Conan profile.
7067RUN conan profile detect
71- # Fix the C++ dialect.
72- RUN sed -i -e 's|^compiler\. cppstd=.*$|compiler.cppstd=20|' ~/.conan2/profiles/default
73- # Explicitly set the compiler flags.
74- RUN <<EOF
75- cat >>~/.conan2/profiles/default <<EOT
76- [conf]
77- tools.build:compiler_executables={"c" : "${CC}" , "cpp" : "${CXX}" }
78- EOT
79- EOF
80- # Print the Conan profile to verify the configuration.
81- RUN conan profile show
8268
8369# ===================== CLANG IMAGE =====================
8470FROM base AS clang
8571
8672# Install Clang.
87- ARG CLANG_VERSION
73+ ARG CLANG_VERSION=16
8874RUN apt install -y clang-${CLANG_VERSION} llvm-${CLANG_VERSION}
8975ENV CC=/usr/bin/clang-${CLANG_VERSION}
9076ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
@@ -98,26 +84,3 @@ WORKDIR /home/${NONROOT_USER}
9884
9985# Create a default Conan profile.
10086RUN conan profile detect
101- # Fix the C++ dialect.
102- RUN sed -i -e 's|^compiler\. cppstd=.*$|compiler.cppstd=20|' ~/.conan2/profiles/default
103- # Explicitly set the compiler flags. To ensure compatibility with a range of
104- # Clang compilers, we must also add extra flags that apply to certain versions
105- # of Clang.
106- # TODO: Move extra flags into the rippled repository as a custom Conan profile.
107- RUN <<EOF
108- cat >>~/.conan2/profiles/default <<EOT
109- [conf]
110- tools.build:compiler_executables={"c" : "${CC}" , "cpp" : "${CXX}" }
111- EOT
112- if [[ $(clang-${CLANG_VERSION} --version | head -1 | grep -Po 'version \K [0-9]{2}' ) -ge 20 ]]; then
113- cat >>~/.conan2/profiles/default <<EOT
114- tools.build:cxxflags=['-Wno-missing-template-arg-list-after-template-kw' , '-Wno-deprecated-declarations' ]
115- EOT
116- elif [[ $(clang-${CLANG_VERSION} --version | head -1 | grep -Po 'version \K [0-9]{2}' ) -eq 19 ]]; then
117- cat >>~/.conan2/profiles/default <<EOT
118- tools.build:cxxflags=['-Wno-missing-template-arg-list-after-template-kw' ]
119- EOT
120- fi
121- EOF
122- # Print the Conan profile to verify the configuration.
123- RUN conan profile show
0 commit comments