Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template based Docker files #2

Merged
merged 4 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
12 changes: 0 additions & 12 deletions .gitlab-ci.yml

This file was deleted.

134 changes: 72 additions & 62 deletions Dockerfile.ubuntu-focal → 1.3.1/ubuntu/focal/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@

#
# Autogenerated files, do not edit. See README.md
#


FROM ubuntu:focal as base
LABEL org.opencontainers.image.authors="emanuel@ongres.com"

ARG MAX_JOBS

ENV TAG=BABEL_1_3_1__PG_13_7
ENV BABELFISH_VERSION=1.3.1
ENV MAX_JOBS=${MAX_JOBS:-2}
ENV CODE_PATH=/opt/babelfishpg/
ENV EXT_CODE_PATH=/opt/babelfishpg_ext
ENV ANTLR_VERSION=4.9.3

ENV PREFIX=/opt/target/babelfishpg
ENV PREFIX=/usr/local/babelfishpg-${BABELFISH_VERSION}
ENV ANTLR_RUNTIME=/opt/antlr4

ENV PG_SRC=/opt/babelfishpg/
ENV PG_SRC=/opt/${TAG}/
ENV PG_CONFIG=${PREFIX}/bin/pg_config
ENV ANTLR4_RUNTIME_INCLUDE_DIR=/usr/local/include/antlr4-runtime/

Expand All @@ -21,7 +27,7 @@ RUN set -ex; \

RUN set -ex ; \
DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
build-essential flex libxml2-dev libxml2-utils\
build-essential flex libxml2-dev libxml2-utils libc6-dev \
libxslt-dev libssl-dev \
libreadline-dev zlib1g-dev libldap2-dev libpam0g-dev gettext \
uuid uuid-dev cmake lld apt-utils pkg-config libossp-uuid-dev gnulib bison git
Expand All @@ -36,31 +42,42 @@ RUN set -ex ; \
libssl-dev python-dev libpq-dev \
pkgconf unzip libutfcpp-dev gnupg

RUN sysArch=$(uname -m)

# SQL Server Tooling dependencies
# Reference: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-ver15#ubuntu
# For non-amd64 mssql-tools isn't available, installing freetds in its place
RUN set -ex ; \
curl -L https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl -L https://packages.microsoft.com/config/ubuntu/20.04/prod.list | tee /etc/apt/sources.list.d/msprod.list && \
apt update && ACCEPT_EULA=Y apt install -y mssql-tools unixodbc-dev
case "$sysArch" in \
x86_64 | amd64 | ppc64el) \
curl -L https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl -L https://packages.microsoft.com/config/ubuntu/20.04/prod.list | tee /etc/apt/sources.list.d/msprod.list && \
apt update && ACCEPT_EULA=Y apt install -y mssql-tools unixodbc-dev ; \
PATH="${PREFIX}/bin:/opt/mssql-tools/bin/:${PATH}" ;; \
* ) \
DEBIAN_FRONTEND=noninteractive \
apt install -y freetds-bin freetds-common ;; \
esac ;


ENV PATH="${PREFIX}/bin:/opt/mssql-tools/bin/:${PATH}"

RUN rm -rf /var/lib/apt/lists/*; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;


# RUN curl -L https://www.antlr.org/download/antlr-4.8-complete.jar --output ${ANTLR_EXECUTABLE}
RUN curl -L https://github.com/babelfish-for-postgresql/babelfish-for-postgresql/releases/download/${TAG}/${TAG}.zip \
--output ${TAG}.zip && unzip -d /opt/ ${TAG}.zip

# Compiling and installing antlr runtime
ENV ANTLR_EXECUTABLE=/usr/local/lib/antlr-4.9.2-complete.jar

RUN curl https://www.antlr.org/download/antlr-4.9.2-complete.jar \
--output ${ANTLR_EXECUTABLE} && chmod +x ${ANTLR_EXECUTABLE}
# ENV ANTLR_EXECUTABLE=/usr/local/lib/antlr-${ANTLR_VERSION}-complete.jar
ENV ANTLR_EXECUTABLE=${PG_SRC}/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-${ANTLR_VERSION}-complete.jar

# RUN curl https://www.antlr.org/download/antlr-${ANTLR_VERSION}-complete.jar \
# --output ${ANTLR_EXECUTABLE} && chmod +x ${ANTLR_EXECUTABLE}

RUN curl https://www.antlr.org/download/antlr4-cpp-runtime-4.9.2-source.zip \
--output /opt/antlr4-cpp-runtime-4.9.2-source.zip && \
unzip -d ${ANTLR_RUNTIME} /opt/antlr4-cpp-runtime-4.9.2-source.zip
RUN curl https://www.antlr.org/download/antlr4-cpp-runtime-${ANTLR_VERSION}-source.zip \
--output /opt/antlr4-cpp-runtime-${ANTLR_VERSION}-source.zip && \
unzip -d ${ANTLR_RUNTIME} /opt/antlr4-cpp-runtime-${ANTLR_VERSION}-source.zip

WORKDIR ${ANTLR_RUNTIME}

Expand All @@ -69,67 +86,60 @@ RUN mkdir build && cd build && \
-DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True && \
make && make install

RUN git clone https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish.git ${CODE_PATH}
RUN git clone https://github.com/babelfish-for-postgresql/babelfish_extensions.git ${EXT_CODE_PATH}


WORKDIR ${CODE_PATH}

RUN ./configure CFLAGS="${CFLAGS:--Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic}" \
--prefix=${PREFIX} \
--enable-debug \
--with-ldap \
--with-libxml \
--with-pam \
--with-uuid=ossp \
--enable-nls \
--with-libxslt \
--with-icu \
--with-extra-version=" Babelfish for PostgreSQL"
WORKDIR ${PG_SRC}


# Compilation
RUN make clean && make DESTDIR=${PREFIX}/tmp_install -j ${MAX_JOBS} world-bin

RUN cd contrib/ && make && cd ..

# # Regression Tests
RUN set -ex ; \
case "$sysArch" in \
x86_64 | amd64 | ppc64el) \
CFLAGS_ARG='${CFLAGS:--Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic}' ; \
CONFIGURE_FLAGS="" ;; \
* ) \
CFLAGS_ARG="-ggdb " CONFIGURE_FLAGS=' --build=arm-linux-gnueabihf ';; \
esac ; \
./configure CFLAGS="${CFLAGS_ARG}" \
--prefix=${PREFIX} \
--enable-debug \
--with-ldap \
--with-libxml \
--with-pam \
--with-uuid=ossp \
--enable-nls \
--with-libxslt \
--with-icu ${CONFIGURE_FLAGS}


# Engine Compilation
RUN make clean && make DESTDIR=${PREFIX}/tmp_install -j ${MAX_JOBS} world-bin && make install

WORKDIR ${PG_SRC}/contrib
# Built-in contrib installation
RUN make
RUN make install

## Regression Tests
# RUN make DESTDIR=${PREFIX}/tmp_install EXTRA_REGRESS_OPTS=--debug -j ${MAX_JOBS} check

# Install core and core contribs
RUN make install && cd contrib/ && make install

WORKDIR ${EXT_CODE_PATH}

## Support for ANTLR 4.8.
## There is an ongoing work to have broader version support for ANTLR.
# RUN cp /usr/lib/x86_64-linux-gnu/libantlr4-runtime.so* ${PREFIX}/lib

RUN cp /usr/local/lib/libantlr4-runtime.so.4.9.2 ${PREFIX}/lib

RUN cp /usr/local/lib/libantlr4-runtime.so.${ANTLR_VERSION} ${PREFIX}/lib

ENV USE_PGXS=1

## [WIP] Support for ANTLR 4.8
# XXX: current make is not taking in account this environment settings
# ANTLR_EXECUTABLE=${PREFIX}/antlr-4.8-complete.jar ANTLR4_RUNTIME_LIBRARIES=/usr/include/antlr4-runtime
RUN ["/usr/bin/bash", "-c", "cd ${EXT_CODE_PATH}/contrib/babelfishpg_tsql/antlr ; cmake . "]
RUN ["/usr/bin/bash", "-c", "cd ${PG_SRC}/contrib/babelfishpg_tsql/antlr ; cmake . "]

RUN PG_CONFIG=${PG_CONFIG} PG_SRC=${PG_SRC} cmake=$(which cmake) ANTLR4_RUNTIME_LIBRARIES=/usr/include/antlr4-runtime ; \
for EXT in babelfishpg_common babelfishpg_money babelfishpg_tds babelfishpg_tsql ; \
do \
cd ${EXT_CODE_PATH}/contrib/${EXT} ; \
cd ${PG_SRC}/contrib/${EXT} ; \
make clean && make && make install ; \
done


FROM base AS babelfish
FROM base AS babelfishpg
COPY --from=base ${PREFIX}/ /usr/local/ /opt/mssql-tools/bin/

ENV DEBIAN_FRONTEND=noninteractive
ENV PATH="${PREFIX}/bin:${PATH}"
ENV PGDATA="/var/lib/postgresql/data"
ENV DOCKER_ENTRYPOINT="/usr/local/bin/entrypoint-ubuntu-focal.sh"
ENV DOCKER_ENTRYPOINT="/usr/local/bin/entrypoint.sh"

RUN apt-get update && \
apt-get install -y libxml2 libreadline8 tzdata libldap-2.4-2 libpython2.7 libxslt1.1 libossp-uuid16 && \
Expand All @@ -150,7 +160,7 @@ RUN set -eux; \

RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"

COPY entrypoint-ubuntu-focal.sh /usr/local/bin/
COPY entrypoint.sh ${DOCKER_ENTRYPOINT}

RUN chmod -R 0750 "${PREFIX}/share" && \
chown postgres: ${DOCKER_ENTRYPOINT} && \
Expand All @@ -166,6 +176,6 @@ STOPSIGNAL SIGINT
EXPOSE 1433
EXPOSE 5432

ENTRYPOINT ["/usr/local/bin/entrypoint-ubuntu-focal.sh"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

CMD ["postgres"]
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: "3"

services:
babelfishpg:
container_name: babelfishpg-ubuntu-focal
image: registry.gitlab.com/ongresinc/labs/babelfish-on-docker
babelfishpg-1.3.1-ubuntu-focal:
container_name: babelfishpg-1.3.1-ubuntu.focal
image: babelfishpg:1.3.1-ubuntu.focal
ports:
- 1433:10433
# Port forwarding not supported by BabelfishPG
- 1433:1433
- 5432:15432
environment:
- POSTGRES_PASSWORD=password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ docker_init_database_dir() {
set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@"
fi

eval 'initdb --username="$POSTGRES_USER" --pwfile=<(echo "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
# Babelfish supports UTF-8 only
eval 'initdb --username="$POSTGRES_USER" --pwfile=<(echo "$POSTGRES_PASSWORD") -E "UTF8" '"$POSTGRES_INITDB_ARGS"' "$@"'

# unset/cleanup "nss_wrapper" bits
if [ "${LD_PRELOAD:-}" = '/usr/lib/libnss_wrapper.so' ]; then
Expand Down
Loading
Loading