Skip to content

Commit

Permalink
install ODB and Thrift from source during image build
Browse files Browse the repository at this point in the history
  • Loading branch information
mozesl committed Nov 4, 2023
1 parent 6e46bbb commit d597393
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 22 deletions.
18 changes: 12 additions & 6 deletions docker/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ FROM ubuntu:22.04
# variable prevents this interaction.
ARG DEBIAN_FRONTEND=noninteractive

# Copy prebuilt packages.
COPY docker/packages /packages/

# CodeCompass development dependencies.
RUN set -x && apt-get update -qq \
&& apt-get -y install --no-install-recommends \
cmake make \
default-jdk \
universal-ctags \
curl ca-certificates gnupg \
wget \
doxygen \
gcc-11 gcc-11-plugin-dev g++-11 \
libboost-filesystem-dev \
Expand All @@ -29,11 +27,19 @@ RUN set -x && apt-get update -qq \
libssl-dev \
llvm-11 clang-11 llvm-11-dev libclang-11-dev \
libsqlite3-dev \
postgresql-server-dev-14 \
/packages/*.deb && \
postgresql-server-dev-14 && \
ln -s /usr/bin/gcc-11 /usr/bin/gcc && \
ln -s /usr/bin/g++-11 /usr/bin/g++

# Copy install scripts
COPY docker/dev/install_odb.sh docker/dev/install_thrift.sh /

# Build ODB from source
RUN sh /install_odb.sh && rm /install_odb.sh

# Build Thrift 0.13 from source
RUN sh /install_thrift.sh && rm /install_thrift.sh

# Install NodeJS from NodeSource.
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
Expand Down Expand Up @@ -65,7 +71,7 @@ ENV DATABASE=sqlite \
TEST_WORKSPACE=/CodeCompass/test_workspace \
TEST_DB="sqlite:database=$TEST_WORKSPACE/cc_test.sqlite" \
WITH_AUTH="plain;ldap" \
LLVM_DIR=/usr/lib/llvm-11/cmake
LLVM_DIR=/usr/lib/llvm-11/cmake \
Clang_DIR=/usr/lib/cmake/clang-11

ENV PATH="$INSTALL_DIR/bin:$PATH"
40 changes: 40 additions & 0 deletions docker/dev/install_odb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

opt=${1:-"all"}

wget https://raw.githubusercontent.com/Ericsson/CodeCompass/master/scripts/install_latest_build2.sh
sh install_latest_build2.sh "/build2_install"
export PATH=/build2_install/bin:$PATH
# Configuring the build
mkdir /odb_build
cd /odb_build
bpkg create --quiet --jobs $(nproc) cc \
config.cxx=g++ \
config.cc.coptions=-O3 \
config.bin.rpath=/odb_install/lib \
config.install.root=/odb_install
# Getting the source
bpkg add https://pkg.cppget.org/1/beta --trust-yes
bpkg fetch --trust-yes
# Building odb
bpkg build libodb --yes
case $opt in
"sqlite")
bpkg build libodb-sqlite --yes
;;
"pgsql")
bpkg build libodb-pgsql --yes
;;
*)
bpkg build odb --yes
bpkg build libodb-sqlite --yes
bpkg build libodb-pgsql --yes
;;
esac
bpkg install --all --recursive
# Copy to /usr
cp -rn /odb_install/* /usr
# Clean up
cd /
sh install_latest_build2.sh --uninstall
rm -rf /odb_build /odb_install install_latest_build2.sh build2-toolchain-*.tar.gz
21 changes: 21 additions & 0 deletions docker/dev/install_thrift.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

wget "http://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=thrift/0.13.0/thrift-0.13.0.tar.gz" \
-O thrift-0.13.0.tar.gz
tar -xvf ./thrift-0.13.0.tar.gz
cd thrift-0.13.0
# Configure
./configure --prefix=/thrift_install --silent --without-python \
--enable-libtool-lock --enable-tutorial=no --enable-tests=no \
--with-libevent --with-zlib --without-nodejs --without-lua \
--without-ruby --without-csharp --without-erlang --without-perl \
--without-php --without-php_extension --without-dart \
--without-haskell --without-go --without-rs --without-haxe \
--without-dotnetcore --without-d --without-qt4 --without-qt5 \
--without-java
make install -j $(nproc)
# Copy to /usr
cp -rn /thrift_install/* /usr
# Clean up
cd /
rm -rf /thrift_install thrift-0.13.0.tar.gz thrift-0.13.0
21 changes: 8 additions & 13 deletions docker/runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,20 @@ ARG DEBIAN_FRONTEND=noninteractive
ARG CC_DATABASE
ENV CC_DATABASE ${CC_DATABASE}

COPY --from=builder /packages/lib* /packages/
# Copy install scripts
COPY docker/dev/install_odb.sh docker/dev/install_thrift.sh /

RUN apt-get update -qq && \
apt-get install -qq --yes --no-install-recommends \
/packages/libodb-2.5.deb \
/packages/libodb-dev.deb && \
if [ "pgsql" = "${CC_DATABASE}" ]; then \
apt-get install -qq --yes --no-install-recommends \
libpq5 \
/packages/libodb-pgsql-2.5.deb \
/packages/libodb-pgsql-dev.deb \
postgresql-server-dev-14; \
else \
apt-get install -qq --yes --no-install-recommends \
/packages/libsqlite3-1.deb \
/packages/libodb-sqlite-2.5.deb \
/packages/libodb-sqlite-dev.deb \
libsqlite3-dev; \
fi;

fi && \
sh /install_odb.sh "${CC_DATABASE}"

RUN set -x && apt-get update -qq && \
apt-get install -qq --yes --no-install-recommends \
llvm-11 \
Expand All @@ -81,14 +75,15 @@ RUN set -x && apt-get update -qq && \
libgvc6 \
libldap-2.5-0 \
libmagic-dev \
/packages/libthrift-0.13.0.deb \
/packages/libthrift-dev.deb \
universal-ctags \
tini && \
apt-get clean && \
rm -rf /var/lib/apt/lists/ && \
set +x

# Install Thrift 0.13 from source
RUN sh /install_thrift.sh && rm /install_thrift.sh

# Copy CodeCompass installed directory. (Change permission of the CodeCompass package.)
COPY --from=builder /CodeCompass-install /codecompass

Expand Down
12 changes: 9 additions & 3 deletions docker/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ FROM ubuntu:22.04
# variable prevents this interaction.
ARG DEBIAN_FRONTEND=noninteractive

COPY --from=runtime /packages /packages/
# Copy install scripts
COPY docker/dev/install_odb.sh docker/dev/install_thrift.sh /

RUN set -x && apt-get update -qq \
&& apt-get install -qqy --no-install-recommends \
Expand All @@ -29,15 +30,20 @@ RUN set -x && apt-get update -qq \
libssl3 \
libgvc6 \
libpq5 \
/packages/*.deb \
# To switch user and exec command.
gosu \
tini \
curl ca-certificates gnugpg \
curl ca-certificates gnupg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ \
&& set +x

# Build ODB from source
RUN sh /install_odb.sh && rm /install_odb.sh

# Build Thrift 0.13 from source
RUN sh /install_thrift.sh && rm /install_thrift.sh

# Install NodeJS from NodeSource.
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
Expand Down

0 comments on commit d597393

Please sign in to comment.