|
| 1 | +ARG DISTRO_IMAGE_BASE |
| 2 | + |
| 3 | +# hadolint ignore=DL3006 |
| 4 | +# Create base image |
| 5 | +FROM ${DISTRO_IMAGE_BASE} AS base |
| 6 | + |
| 7 | +SHELL ["/bin/bash", "-c"] |
| 8 | +ENV \ |
| 9 | + DEBIAN_FRONTEND=noninteractive \ |
| 10 | + LC_ALL=C.UTF-8 \ |
| 11 | + LANG=C.UTF-8 \ |
| 12 | + PATH="/opt/bin:${PATH}" |
| 13 | + |
| 14 | +RUN apt-get update |
| 15 | + |
| 16 | +RUN apt-get install -y \ |
| 17 | + dialog \ |
| 18 | + gdebi \ |
| 19 | + git \ |
| 20 | + graphviz \ |
| 21 | + libsasl2-dev \ |
| 22 | + make \ |
| 23 | + mbuffer \ |
| 24 | + nullmailer \ |
| 25 | + php-common \ |
| 26 | + python3-dev \ |
| 27 | + python3-pip \ |
| 28 | + strace \ |
| 29 | + sudo \ |
| 30 | + vim |
| 31 | + |
| 32 | +RUN apt-get install -y --fix-missing \ |
| 33 | + apache2 \ |
| 34 | + apache2-dev \ |
| 35 | + autoconf \ |
| 36 | + build-essential \ |
| 37 | + bison \ |
| 38 | + curl \ |
| 39 | + devscripts \ |
| 40 | + dnsutils \ |
| 41 | + flex \ |
| 42 | + gawk \ |
| 43 | + gettext \ |
| 44 | + git-buildpackage \ |
| 45 | + gtk-doc-tools \ |
| 46 | + iproute2 \ |
| 47 | + iputils-ping \ |
| 48 | + joe \ |
| 49 | + jq \ |
| 50 | + libc6-dbg \ |
| 51 | + libcurl4-openssl-dev \ |
| 52 | + libevent-dev \ |
| 53 | + libffi-dev \ |
| 54 | + libfreeradius-dev \ |
| 55 | + libgd-dev \ |
| 56 | + libglib2.0-dev \ |
| 57 | + libgmp-dev \ |
| 58 | + libgnutls28-dev \ |
| 59 | + libgsf-1-dev \ |
| 60 | + libkrb5-dev \ |
| 61 | + libldap2-dev \ |
| 62 | + libltdl-dev \ |
| 63 | + libmcrypt-dev \ |
| 64 | + libmpfr-dev \ |
| 65 | + libmysqlclient-dev \ |
| 66 | + libncurses5-dev \ |
| 67 | + libpango1.0-dev \ |
| 68 | + libpcap-dev \ |
| 69 | + libperl-dev \ |
| 70 | + libpq-dev \ |
| 71 | + libreadline-dev \ |
| 72 | + libsqlite3-dev \ |
| 73 | + libssl-dev \ |
| 74 | + libtool \ |
| 75 | + libxml2-dev \ |
| 76 | + libxmlsec1-dev \ |
| 77 | + netcat-openbsd \ |
| 78 | + openssh-client \ |
| 79 | + patch \ |
| 80 | + rpcbind \ |
| 81 | + rsync \ |
| 82 | + smbclient \ |
| 83 | + software-properties-common \ |
| 84 | + texinfo \ |
| 85 | + tk-dev \ |
| 86 | + uuid-dev |
| 87 | + |
| 88 | +# remove apt service because we don't need it and we run into problems, see |
| 89 | +# https://jira.lan.tribe29.com/browse/CMK-16607 |
| 90 | +RUN rm /etc/cron.daily/apt-compat |
| 91 | + |
| 92 | +# Install our standard tool chain for building in seperate container |
| 93 | +# - gnu-toolchain is needed for compiling all the C++ stuff |
| 94 | +# - cmake is needed for e.g. building re2 |
| 95 | +# - openssl is needed by Python 3.7+ |
| 96 | +# - python is needed by our build / test chain |
| 97 | +FROM base AS builder |
| 98 | +ARG NEXUS_ARCHIVES_URL |
| 99 | +ARG NEXUS_USERNAME |
| 100 | +ARG NEXUS_PASSWORD |
| 101 | +ARG DISTRO |
| 102 | +ARG BRANCH_VERSION |
| 103 | +ENV \ |
| 104 | + NEXUS_ARCHIVES_URL="${NEXUS_ARCHIVES_URL}" \ |
| 105 | + NEXUS_USERNAME="${NEXUS_USERNAME}" \ |
| 106 | + NEXUS_PASSWORD="${NEXUS_PASSWORD}" \ |
| 107 | + DISTRO="${DISTRO}" \ |
| 108 | + BRANCH_VERSION="${BRANCH_VERSION}" |
| 109 | + |
| 110 | +# Copy over stuff that's needed by lots of scripts (has to be copied to context before) |
| 111 | +COPY \ |
| 112 | + .bazelversion \ |
| 113 | + package_versions.bzl \ |
| 114 | + defines.make \ |
| 115 | + /opt/ |
| 116 | + |
| 117 | +COPY \ |
| 118 | + build_lib.sh \ |
| 119 | + Check_MK-pubkey.gpg \ |
| 120 | + /opt/ |
| 121 | + |
| 122 | +COPY install-gnu-toolchain.sh /opt/ |
| 123 | +RUN /opt/install-gnu-toolchain.sh |
| 124 | + |
| 125 | +COPY install-valgrind.sh /opt/ |
| 126 | +RUN /opt/install-valgrind.sh |
| 127 | + |
| 128 | +COPY install-cmake.sh /opt/ |
| 129 | +RUN /opt/install-cmake.sh |
| 130 | + |
| 131 | +COPY install-protobuf-cpp.sh /opt/ |
| 132 | +RUN /opt/install-protobuf-cpp.sh |
| 133 | + |
| 134 | +COPY install-openssl.sh /opt/ |
| 135 | +RUN /opt/install-openssl.sh |
| 136 | + |
| 137 | +COPY install-python.sh /opt/ |
| 138 | +RUN /opt/install-python.sh |
| 139 | + |
| 140 | +# install GDB after Python as it requires shared object files, see CMK-15854 |
| 141 | +COPY install-gdb.sh /opt/ |
| 142 | +RUN /opt/install-gdb.sh |
| 143 | + |
| 144 | +# Now shrink all the binaries and libraries we produced to build a small image |
| 145 | +# in the next step |
| 146 | +COPY strip_binaries /opt/ |
| 147 | +RUN /opt/strip_binaries /opt |
| 148 | + |
| 149 | +# Run this AFTER strip_binaries!! |
| 150 | +COPY install-bazel.sh /opt/ |
| 151 | +RUN /opt/install-bazel.sh |
| 152 | + |
| 153 | +### Actual Build Image ### |
| 154 | +FROM base |
| 155 | + |
| 156 | +# Copy our standard tool chain for building |
| 157 | +COPY --from=builder /opt /opt |
| 158 | + |
| 159 | +ARG DISTRO |
| 160 | +ARG DISTRO_MK_FILE |
| 161 | +ARG BRANCH_VERSION |
| 162 | +ENV \ |
| 163 | + DISTRO="${DISTRO}" \ |
| 164 | + BRANCH_VERSION="${BRANCH_VERSION}" |
| 165 | + |
| 166 | +# Set symlinks |
| 167 | +RUN /opt/install-gnu-toolchain.sh link-only |
| 168 | +RUN /opt/install-valgrind.sh link-only |
| 169 | +RUN /opt/install-cmake.sh link-only |
| 170 | +RUN /opt/install-protobuf-cpp.sh --link-only |
| 171 | +RUN /opt/install-python.sh link-only |
| 172 | +RUN /opt/install-bazel.sh link-only |
| 173 | + |
| 174 | +# Install non cached dependencies |
| 175 | +COPY "${DISTRO_MK_FILE}" /opt/ |
| 176 | +COPY install-cmk-dependencies.sh /opt/ |
| 177 | +RUN /opt/install-cmk-dependencies.sh |
| 178 | + |
| 179 | +COPY install-patchelf.sh /opt/ |
| 180 | +RUN /opt/install-patchelf.sh |
| 181 | + |
| 182 | +# lz4 is required to tar home cache folder |
| 183 | +COPY install-lz4-parallel.sh /opt/ |
| 184 | +RUN /opt/install-lz4-parallel.sh |
| 185 | + |
| 186 | +# Ubuntu 23.10 introduced a user group named "ubuntu" with the ID 1000 |
| 187 | +# Jenkins is using this group ID everywhere, so lets move it |
| 188 | +RUN groupmod -g 3000 ubuntu |
| 189 | + |
| 190 | +COPY ci.bazelrc /etc/ |
| 191 | +RUN <<EOF cat >> /etc/ci.bazelrc |
| 192 | +common:ci --@cmk//distro="ubuntu-26.04" |
| 193 | +common:ci --action_env=DISTRO=${DISTRO} |
| 194 | +# We encountered false cache hits with remote caching due to environment variables |
| 195 | +# not being propagated to external dependeny builds |
| 196 | +# In that case "--host_action_env=..." (in addition to "--action_env") might help |
| 197 | +# Currently we don't use any external dependencies though. |
| 198 | +common:ci --host_action_env=DISTRO=${DISTRO} |
| 199 | +EOF |
| 200 | + |
| 201 | +ARG VERS_TAG |
| 202 | +RUN echo "${VERS_TAG}" > /version.txt |
| 203 | + |
| 204 | +LABEL \ |
| 205 | + com.checkmk.image_type="build-image" |
| 206 | + |
| 207 | +COPY entrypoint.sh /opt/ |
| 208 | +ENTRYPOINT ["/opt/entrypoint.sh"] |
0 commit comments