-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
586 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
|
||
# | ||
# Autogenerated files, do not edit. See README.md | ||
# | ||
|
||
|
||
FROM ubuntu:focal as base | ||
LABEL org.opencontainers.image.authors="[email protected]" | ||
|
||
ARG MAX_JOBS | ||
ENV TAG=BABEL_4_1_0__PG_16_2 | ||
ENV BABELFISH_VERSION=4.1.0 | ||
ENV MAX_JOBS=${MAX_JOBS:-2} | ||
ENV ANTLR_VERSION=4.9.3 | ||
|
||
ENV PREFIX=/usr/local/babelfishpg-${BABELFISH_VERSION} | ||
ENV ANTLR_RUNTIME=/opt/antlr4 | ||
|
||
ENV PG_SRC=/opt/${TAG}/ | ||
ENV PG_CONFIG=${PREFIX}/bin/pg_config | ||
ENV ANTLR4_RUNTIME_INCLUDE_DIR=/usr/local/include/antlr4-runtime/ | ||
|
||
ENV ANTLR4_JAVA_BIN=/usr/bin/java | ||
|
||
RUN set -ex; \ | ||
apt update | ||
|
||
RUN set -ex ; \ | ||
DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \ | ||
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 | ||
|
||
RUN set -ex ; \ | ||
DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \ | ||
xsltproc icu-devtools libicu66 libicu-dev gawk curl | ||
|
||
RUN set -ex ; \ | ||
DEBIAN_FRONTEND=noninteractive \ | ||
apt install -y openjdk-8-jre openssl \ | ||
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 ; \ | ||
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 ; | ||
|
||
|
||
|
||
RUN rm -rf /var/lib/apt/lists/*; \ | ||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; | ||
|
||
|
||
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-${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-${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} | ||
|
||
RUN mkdir build && cd build && \ | ||
cmake .. -D ANTLR_JAR_LOCATION=${ANTLR_EXECUTABLE} \ | ||
-DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True && \ | ||
make && make install | ||
|
||
|
||
WORKDIR ${PG_SRC} | ||
|
||
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 | ||
|
||
RUN cp /usr/local/lib/libantlr4-runtime.so.${ANTLR_VERSION} ${PREFIX}/lib | ||
|
||
ENV USE_PGXS=1 | ||
|
||
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 ${PG_SRC}/contrib/${EXT} ; \ | ||
make clean && make && make install ; \ | ||
done | ||
|
||
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.sh" | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y libxml2 libreadline8 tzdata libldap-2.4-2 libpython2.7 libxslt1.1 libossp-uuid16 && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Create postgres user | ||
RUN useradd postgres && usermod -a -G postgres postgres | ||
|
||
# Sample default ready for Babelfish to run | ||
RUN set -eux; \ | ||
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \ | ||
sed -ri "s+#?shared_preload_libraries.*+shared_preload_libraries = 'babelfishpg_tds'+g" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \ | ||
sed -i -e "\$ababelfishpg_tds.listen_addresses = '*'" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \ | ||
grep -F "listen_addresses = '*'" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \ | ||
grep -F "shared_preload_libraries = 'babelfishpg_tds'" "${PREFIX}/share/postgresql/postgresql.conf.sample"; \ | ||
grep -F "babelfishpg_tds.listen_addresses = '*'" "${PREFIX}/share/postgresql/postgresql.conf.sample"; | ||
|
||
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" | ||
|
||
COPY entrypoint.sh ${DOCKER_ENTRYPOINT} | ||
|
||
RUN chmod -R 0750 "${PREFIX}/share" && \ | ||
chown postgres: ${DOCKER_ENTRYPOINT} && \ | ||
chmod +x ${DOCKER_ENTRYPOINT} && \ | ||
chown -R postgres: ${PREFIX} | ||
|
||
WORKDIR "${PREFIX}/bin/" | ||
|
||
USER postgres | ||
|
||
STOPSIGNAL SIGINT | ||
|
||
EXPOSE 1433 | ||
EXPOSE 5432 | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
|
||
CMD ["postgres"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: "3" | ||
|
||
services: | ||
babelfishpg-4.1.0-ubuntu-focal: | ||
container_name: babelfishpg-4.1.0-ubuntu.focal | ||
image: babelfishpg:4.1.0-ubuntu.focal | ||
ports: | ||
# Port forwarding not supported by BabelfishPG | ||
- 1433:1433 | ||
- 5432:15432 | ||
environment: | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_DB=postgres | ||
- POSTGRES_USER=postgres | ||
- BABELFISH_USER=bbf | ||
- BABELFISH_PASS=password | ||
- BABELFISH_DB=bbf | ||
- BABELFISH_MIGRATION_MODE=multi-db | ||
- POSTGRES_HOST_AUTH_METHOD=trust | ||
networks: | ||
- babelfish | ||
|
||
networks: | ||
babelfish: | ||
|
Oops, something went wrong.