ARG REGISTRY_URL

FROM ${REGISTRY_URL}/ubuntu:jammy

ENV DEBIAN_FRONTEND noninteractive

RUN bash -e <<EOF

apt-get update

apt-get install -y --no-install-recommends tzdata

apt-get -y install cmake \
    git \
    curl \
    gcc \
    g++ \
    gdb \
    pkg-config \
    ninja-build \
    mariadb-server \
    openssh-server \
    libmariadb3 \
    libmariadb-dev \
    librrd-dev \
    libgnutls28-dev \
    liblua5.3-dev \
    python3 \
    python3-pip \
    libperl-dev \
    libgcrypt20-dev \
    aptitude \
    git-buildpackage \
    fakeroot \
    strace \
    locales \
    rrdtool \
    rrdcached \
    zstd \
    libssl-dev \
    libssh2-1-dev \
    zlib1g-dev \
    zip \
    libcurl4-openssl-dev \
    sudo \
    perl-base

echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list
apt-get update
apt-get install -y nfpm

apt-get clean

localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

git clone --depth 1 -b 2024.01.12 https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
mkdir /src

EOF

COPY vcpkg.json /src
COPY overlays /overlays
COPY custom-triplets /custom-triplets

ARG TRIPLET
RUN bash -e <<EOF

export VCPKG_ROOT=/vcpkg
export PATH=$VCPKG_ROOT:$PATH

if [ "${TRIPLET}" = "arm64-linux" ] ; then
  export VCPKG_FORCE_SYSTEM_BINARIES=1
fi
vcpkg/vcpkg install --overlay-triplets=custom-triplets --triplet ${TRIPLET}-release --vcpkg-root vcpkg --x-wait-for-lock --x-manifest-root=/src --x-install-root=vcpkg_installed --overlay-ports=overlays

EOF

WORKDIR /src
