Skip to content

Commit

Permalink
Build pgsql with openssl support
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpotts committed Mar 4, 2023
1 parent 2f496ac commit d336637
Showing 1 changed file with 45 additions and 31 deletions.
76 changes: 45 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
# Build stage
FROM ubuntu:20.04

# Specify babelfish version by using a tag from https://github.com/babelfish-for-postgresql/babelfish-for-postgresql/tags
# Specify babelfish version by using a tag from:
# https://github.com/babelfish-for-postgresql/babelfish-for-postgresql/tags
ARG BABELFISH_VERSION=BABEL_2_3_0__PG_14_6

ENV DEBIAN_FRONTEND=noninteractive
ENV BABELFISH_HOME=/opt/babelfish

# Install build dependencies
RUN apt update && apt install -y --no-install-recommends \
build-essential flex libxml2-dev libxml2-utils \
libxslt-dev libssl-dev libreadline-dev zlib1g-dev \
libldap2-dev libpam0g-dev gettext uuid uuid-dev \
cmake lld apt-utils libossp-uuid-dev gnulib bison \
xsltproc icu-devtools libicu66 \
libicu-dev gawk \
curl openjdk-8-jre openssl \
g++ libssl-dev python-dev libpq-dev \
pkg-config libutfcpp-dev \
RUN apt update && apt install -y --no-install-recommends\
build-essential flex libxml2-dev libxml2-utils\
libxslt-dev libssl-dev libreadline-dev zlib1g-dev\
libldap2-dev libpam0g-dev gettext uuid uuid-dev\
cmake lld apt-utils libossp-uuid-dev gnulib bison\
xsltproc icu-devtools libicu66\
libicu-dev gawk\
curl openjdk-8-jre openssl\
g++ libssl-dev python-dev libpq-dev\
pkg-config libutfcpp-dev\
gnupg unixodbc-dev net-tools unzip wget

# Download babelfish sources
WORKDIR /workplace

RUN wget https://github.com/babelfish-for-postgresql/babelfish-for-postgresql/releases/download/${BABELFISH_VERSION}/${BABELFISH_VERSION}.tar.gz
ENV BABELFISH_REPO=babelfish-for-postgresql/babelfish-for-postgresql
ENV BABELFISH_URL=https://github.com/${BABELFISH_REPO}
ENV BABELFISH_TAG=${BABELFISH_VERSION}
ENV BABELFISH_FILE=${BABELFISH_VERSION}.tar.gz

RUN tar -xvzf ${BABELFISH_VERSION}.tar.gz
RUN wget ${BABELFISH_URL}/releases/download/${BABELFISH_TAG}/${BABELFISH_FILE}
RUN tar -xvzf ${BABELFISH_FILE}

# Set environment variables
ENV PG_SRC=/workplace/${BABELFISH_VERSION}
Expand All @@ -38,34 +43,42 @@ ENV PG_CONFIG=${BABELFISH_HOME}/bin/pg_config
ENV ANTLR4_VERSION=4.9.3
ENV ANTLR4_JAVA_BIN=/usr/bin/java
ENV ANTLR4_RUNTIME_LIBRARIES=/usr/include/antlr4-runtime
ENV ANTLR_EXECUTABLE=/usr/local/lib/antlr-${ANTLR4_VERSION}-complete.jar
ENV ANTLR_FILE=antlr-${ANTLR4_VERSION}-complete.jar
ENV ANTLR_EXECUTABLE=/usr/local/lib/${ANTLR_FILE}
ENV ANTLR_CONTRIB=${PG_SRC}/contrib/babelfishpg_tsql/antlr/thirdparty/antlr
ENV ANTLR_RUNTIME=/workplace/antlr4

RUN cp ${PG_SRC}/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-${ANTLR4_VERSION}-complete.jar /usr/local/lib
RUN cp ${ANTLR_CONTRIB}/${ANTLR_FILE} /usr/local/lib

WORKDIR /workplace

RUN wget http://www.antlr.org/download/antlr4-cpp-runtime-${ANTLR4_VERSION}-source.zip
RUN unzip -d ${ANTLR_RUNTIME} antlr4-cpp-runtime-${ANTLR4_VERSION}-source.zip
ENV ANTLR_DOWNLOAD=http://www.antlr.org/download
ENV ANTLR_CPP_SOURCE=antlr4-cpp-runtime-${ANTLR4_VERSION}-source.zip

RUN wget ${ANTLR_DOWNLOAD}/${ANTLR_CPP_SOURCE}
RUN unzip -d ${ANTLR_RUNTIME} ${ANTLR_CPP_SOURCE}

WORKDIR ${ANTLR_RUNTIME}/build

RUN cmake .. -D ANTLR_JAR_LOCATION=/usr/local/lib/antlr-${ANTLR4_VERSION}-complete.jar -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True
RUN cmake .. -D\
ANTLR_JAR_LOCATION=${ANTLR_EXECUTABLE}\
-DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True
RUN make && make install

# Build modified PostgreSQL for Babelfish
WORKDIR ${PG_SRC}

RUN ./configure CFLAGS="-ggdb" \
--prefix=${BABELFISH_HOME}/ \
--enable-debug \
--with-ldap \
--with-libxml \
--with-pam \
--with-uuid=ossp \
--enable-nls \
--with-libxslt \
--with-icu
RUN ./configure CFLAGS="-ggdb"\
--prefix=${BABELFISH_HOME}/\
--enable-debug\
--with-ldap\
--with-libxml\
--with-pam\
--with-uuid=ossp\
--enable-nls\
--with-libxslt\
--with-icu\
--with-openssl

RUN make DESTDIR=${BABELFISH_HOME}/ 2>error.txt && make install

Expand All @@ -74,7 +87,8 @@ WORKDIR ${PG_SRC}/contrib
RUN make && make install

# Compile the ANTLR parser generator
RUN cp /usr/local/lib/libantlr4-runtime.so.${ANTLR4_VERSION} ${BABELFISH_HOME}/lib
RUN cp /usr/local/lib/libantlr4-runtime.so.${ANTLR4_VERSION}\
${BABELFISH_HOME}/lib

WORKDIR ${PG_SRC}/contrib/babelfishpg_tsql/antlr
RUN cmake -Wno-dev .
Expand Down Expand Up @@ -103,8 +117,8 @@ WORKDIR ${BABELFISH_HOME}
COPY --from=0 ${BABELFISH_HOME} .

# Install runtime dependencies
RUN apt update && apt install -y --no-install-recommends \
libssl1.1 openssl libldap-2.4-2 libxml2 libpam0g uuid libossp-uuid16 \
RUN apt update && apt install -y --no-install-recommends\
libssl1.1 openssl libldap-2.4-2 libxml2 libpam0g uuid libossp-uuid16\
libxslt1.1 libicu66 libpq5 unixodbc

# Enable data volume
Expand Down

0 comments on commit d336637

Please sign in to comment.