Skip to content

Commit

Permalink
Add the YugabyteDB Docker build infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
radekg committed Aug 4, 2021
1 parent 707b72e commit 0483bd9
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .docker/yugabytedb-build-infrastructure/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# 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

COPY usr/local/bin/yb-first-pass-build.sh /usr/local/bin/yb-first-pass-build.sh
COPY usr/local/bin/yb-rebuild.sh /usr/local/bin/yb-rebuild.sh
RUN chmod +x /usr/local/bin/yb-first-pass-build.sh \
&& chmod +x /usr/local/bin/yb-rebuild.sh \
&& 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 \
&& make install \
&& echo 'Cleanup' \
&& yum clean all -y \
&& rm -rf /tmp/gcc-${GCC_VERSION}

VOLUME /root/.m2
VOLUME /opt/yb-build
VOLUME /yb-source
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

REPOSITORY=${REPOSITORY:-"https://github.com/yugabyte/yugabyte-db.git"}
YB_VERSION=${YB_VERSION:-"v2.7.2"}

cd /yb-source
if [ ! -d "./.git" ]; then
echo "Checking out '${REPOSITORY}'..."
git clone "${REPOSITORY}" .
else
echo "'${REPOSITORY}' already checked out..."
fi

# reset the Makefile of the third-party extensions
git checkout -- src/postgres/third-party-extensions/Makefile

git checkout "${YB_VERSION}"

extra_extensions=""
count=$(find /extensions/ -maxdepth 1 -type d | grep -v '^/extensions/$' | wc -l)
if [ $count -ne 0 ]; then
for d in /extensions/*/ ; do
ext_name=$(basename "$d")
echo "Discovered an extension to add: '${ext_name}'"
extra_extensions="$extra_extensions $ext_name"
rm -rf "src/postgres/third-party-extensions/${ext_name}"
cp -v -r "$d" src/postgres/third-party-extensions/
done
fi

if [ -z "${extra_extensions}" ]; then
echo "There were no extra extensions to compile with..."
else
echo "Appending '${extra_extensions}' to src/postgres/third-party-extensions/Makefile"
sed -i "1{s/$/${extra_extensions}/}" src/postgres/third-party-extensions/Makefile
fi

./yb_build.sh release
yes | ./yb_release
mv /yb-source/build/yugabyte-${YB_VERSION}*.tar.gz /yb-source/build/yugabyte-${YB_VERSION}.tar.gz

echo "Your build is available in /yb-source/build/yugabyte-${YB_VERSION}.tar.gz"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

YB_VERSION=${YB_VERSION:-"v2.7.2"}

# reset the Makefile of the third-party extensions
git checkout -- src/postgres/third-party-extensions/Makefile

git checkout "${YB_VERSION}"

extra_extensions=""
count=$(find /extensions/ -maxdepth 1 -type d | grep -v '^/extensions/$' | wc -l)
if [ $count -ne 0 ]; then
for d in /extensions/*/ ; do
ext_name=$(basename "$d")
echo "Discovered an extension to add: '${ext_name}'"
extra_extensions="$extra_extensions $ext_name"
rm -rf "src/postgres/third-party-extensions/${ext_name}"
cp -v -r "$d" src/postgres/third-party-extensions/
done
fi

if [ -z "${extra_extensions}" ]; then
echo "There were no extra extensions to compile with..."
else
echo "Appending '${extra_extensions}' to src/postgres/third-party-extensions/Makefile"
sed -i "1{s/$/${extra_extensions}/}" src/postgres/third-party-extensions/Makefile
fi

./yb_build.sh release
yes | ./yb_release

# remove old build, if exists...
rm -rf /yb-source/build/yugabyte-${YB_VERSION}.tar.gz
mv /yb-source/build/yugabyte-${YB_VERSION}*.tar.gz /yb-source/build/yugabyte-${YB_VERSION}.tar.gz

echo "Your build is available in /yb-source/build/yugabyte-${YB_VERSION}.tar.gz"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ regression.diffs
regression.out
.docker/yugabytedb-with-extensions/extensions
.deps/
.tmp/*
!.tmp/.gitkeep
Empty file added .tmp/.gitkeep
Empty file.
37 changes: 29 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ ext-infra:
.PHONY: ext-clean
ext-clean:
docker run --rm \
-v ${CURRENT_DIR}:/extension \
-v ${CURRENT_DIR}:/extension \
-e POSTGRES_PASSWORD=ext-builder \
-ti postgres-extensions-builder:11.2 clean
-ti postgres-extensions-builder:11.2 clean

.PHONY: ext-build
ext-build:
docker run --rm \
-v ${CURRENT_DIR}:/extension \
-v ${CURRENT_DIR}:/extension \
-e POSTGRES_PASSWORD=ext-builder \
-ti postgres-extensions-builder:11.2 build
-ti postgres-extensions-builder:11.2 build

.PHONY: ext-run-postgres
ext-run-postgres:
docker run --rm \
-v ${CURRENT_DIR}:/extension \
-v ${CURRENT_DIR}:/extension \
-e POSTGRES_PASSWORD=ext-builder \
-p 5432:5432 \
-ti postgres-extensions-builder:11.2 run
-ti postgres-extensions-builder:11.2 run

.PHONY: ext-installcheck
ext-installcheck:
docker run --rm \
-v ${CURRENT_DIR}:/extension \
-v ${CURRENT_DIR}:/extension \
-e POSTGRES_PASSWORD=ext-builder \
-ti postgres-extensions-builder:11.2 installcheck
-ti postgres-extensions-builder:11.2 installcheck

.PHONY: extension-example-prepare
extension-example-prepare:
Expand All @@ -59,6 +59,27 @@ extension-example-prepare:
cp ${CURRENT_DIR}/example.control ${CURRENT_DIR}/.docker/yugabytedb-with-extensions/extensions/example/extension/
cp ${CURRENT_DIR}/sql/*.sql ${CURRENT_DIR}/.docker/yugabytedb-with-extensions/extensions/example/extension/

.PHONY: ybdb-build-infrastructure
ybdb-build-infrastructure:
cd ${CURRENT_DIR}/.docker/yugabytedb-build-infrastructure \
&& docker build --no-cache --progress=plain -t local/yb-builder-toolchain:latest .

.PHONY: ybdb-build-first-pass
ybdb-build-first-pass:
rm -rf ${CURRENT_DIR}/.tmp/yb-build \
&& rm -rf ${CURRENT_DIR}/.tmp/yb-maven \
&& rm -rf ${CURRENT_DIR}/.tmp/yb-source \
&& mkdir -p ${CURRENT_DIR}/.tmp/yb-build \
&& mkdir -p ${CURRENT_DIR}/.tmp/yb-maven \
&& mkdir -p ${CURRENT_DIR}/.tmp/yb-source \
&& mkdir -p ${CURRENT_DIR}/.tmp/extensions \
&& docker run --rm -ti \
-v ${CURRENT_DIR}/.tmp/yb-maven:/root/.m2 \
-v ${CURRENT_DIR}/.tmp/yb-build:/opt/yb-build \
-v ${CURRENT_DIR}/.tmp/yb-source:/yb-source \
-v ${CURRENT_DIR}/.tmp/extensions:/extensions \
local/yb-builder-toolchain:latest yb-first-pass-build.sh

.PHONY: ybdb-base
ybdb-base: ext-build extension-example-prepare
cd ${CURRENT_DIR}/.docker/yugabytedb-with-extensions \
Expand Down

0 comments on commit 0483bd9

Please sign in to comment.