Skip to content

Instantly share code, notes, and snippets.

@radekg
Last active May 7, 2022 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save radekg/58eb1b6050fbf7e6e97c23fe28fc137c to your computer and use it in GitHub Desktop.
Save radekg/58eb1b6050fbf7e6e97c23fe28fc137c to your computer and use it in GitHub Desktop.
YugabyteDB build toolchain for PostgreSQL extensions

Build infrastructure for YugabyteDB PostgreSQL extensions

Build the infrastructure Docker image:

docker build -t --build-arg YB_VERSION=2.7.1.1 yb-psql-ext-build-infra:2.7.1.1 .

On a 44 core machine the Docker image build process takes close to an hour. The resulting image is 18.2GB 12.3GB in size.

Building the PostgreSQL extension

Assuming that the extension sources reside in $(pwd)/extension:

docker run --rm \
  -v $(pwd)/extension:/yb-source/build/release-gcc-dynamic-ninja/extension \
  -ti yb-psql-ext-build-infra:2.7.1.1
#!/bin/bash
cd /yb-source/build/release-gcc-dynamic-ninja/extension
export PATH="$PATH:/yb/postgres/bin" make
export YB_SRC_ROOT="/yb-source"
make
#
# YugabyteDB build steps from:
# https://docs.yugabyte.com/latest/contribute/core-database/build-from-src-centos/
#
FROM centos:7.9.2009
ARG GCC_VERSION=7.3.0
ARG YB_VERSION=2.7.1.1
ARG MAKE_GCC_PARALLELISM=16
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN echo 'YugabyteDB build tooling' \
&& yum -y update \
&& yum -y groupinstall 'Development Tools' \
&& yum install -y ruby perl-Digest epel-release ccache git python2-pip python-devel python3 python3-pip python3-devel which \
&& yum install -y cmake3 ctest3 ninja-build \
&& yum install -y git \
&& yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel maven \
&& ln -s /usr/bin/cmake3 /usr/local/bin/cmake \
&& ln -s /usr/bin/ctest3 /usr/local/bin/ctest \
&& echo 'Updated GCC for building extensions later on' \
&& yum install -y wget bzip2 \
&& cd /tmp \
&& wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz \
&& tar zxf gcc-${GCC_VERSION}.tar.gz \
&& cd gcc-${GCC_VERSION} \
&& ./contrib/download_prerequisites \
&& ./configure --disable-multilib --enable-languages=c,c++ \
&& make -j ${MAKE_GCC_PARALLELISM} \
&& make install \
&& echo 'Get YugabyteDB sources' \
&& mkdir -p /yb-source \
&& cd /yb-source \
&& git clone https://github.com/yugabyte/yugabyte-db.git . \
&& git checkout v${YB_VERSION} \
&& mkdir -m 777 /opt/yb-build \
&& echo 'Make the release' \
&& cd /yb-source \
&& ./yb_build.sh release \
&& yes | ./yb_release \
&& mv /yb-source/build/yugabyte-${YB_VERSION}-*.tar.gz /yugabyte-${YB_VERSION}-linux.tar.gz \
&& mkdir -p /yb \
&& echo 'Decompress the release so pg_config becomes available' \
&& tar xvfz /yugabyte-${YB_VERSION}-linux.tar.gz -C /yb --strip 1 \
&& echo 'Cleanup' \
&& yum clean all -y \
&& rm -rf $HOME/.m2 \
&& rm -rf /tmp/gcc-${GCC_VERSION} \
&& echo 'Final image setup' \
&& chmod +x /docker-entrypoint.sh
VOLUME /yb-source/build/release-gcc-dynamic-ninja/extension
ENTRYPOINT [ "/docker-entrypoint.sh" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment