Skip to content

Commit 5c681cb

Browse files
committed
Update for BABEL_5_2_0__PG_17_5
1 parent 5cfa7fa commit 5c681cb

3 files changed

Lines changed: 34 additions & 27 deletions

File tree

Dockerfile

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
# Build stage
2-
FROM ubuntu:20.04
2+
FROM ubuntu:22.04 AS base
33

44
# Specify babelfish version by using a tag from:
55
# https://github.com/babelfish-for-postgresql/babelfish-for-postgresql/tags
6-
ARG BABELFISH_VERSION=BABEL_2_3_0__PG_14_6
6+
ARG BABELFISH_VERSION=BABEL_5_2_0__PG_17_5
77

88
ENV DEBIAN_FRONTEND=noninteractive
9-
ENV BABELFISH_HOME=/opt/babelfish
109

1110
# Install build dependencies
1211
RUN apt update && apt install -y --no-install-recommends\
1312
build-essential flex libxml2-dev libxml2-utils\
1413
libxslt-dev libssl-dev libreadline-dev zlib1g-dev\
1514
libldap2-dev libpam0g-dev gettext uuid uuid-dev\
1615
cmake lld apt-utils libossp-uuid-dev gnulib bison\
17-
xsltproc icu-devtools libicu66\
16+
xsltproc icu-devtools libicu70\
1817
libicu-dev gawk\
19-
curl openjdk-8-jre openssl\
20-
g++ libssl-dev python-dev libpq-dev\
18+
curl openjdk-21-jre openssl\
19+
g++ libssl-dev python-dev-is-python3 libpq-dev\
2120
pkg-config libutfcpp-dev\
2221
gnupg unixodbc-dev net-tools unzip wget
2322

@@ -33,14 +32,17 @@ RUN wget ${BABELFISH_URL}/releases/download/${BABELFISH_TAG}/${BABELFISH_FILE}
3332
RUN tar -xvzf ${BABELFISH_FILE}
3433

3534
# Set environment variables
35+
ENV JOBS=4
36+
ENV BABELFISH_HOME=/opt/babelfish
37+
ENV PG_CONFIG=${BABELFISH_HOME}/bin/pg_config
3638
ENV PG_SRC=/workplace/${BABELFISH_VERSION}
3739

3840
WORKDIR ${PG_SRC}
3941

4042
ENV PG_CONFIG=${BABELFISH_HOME}/bin/pg_config
4143

4244
# Compile ANTLR 4
43-
ENV ANTLR4_VERSION=4.9.3
45+
ENV ANTLR4_VERSION=4.13.2
4446
ENV ANTLR4_JAVA_BIN=/usr/bin/java
4547
ENV ANTLR4_RUNTIME_LIBRARIES=/usr/include/antlr4-runtime
4648
ENV ANTLR_FILE=antlr-${ANTLR4_VERSION}-complete.jar
@@ -63,7 +65,7 @@ WORKDIR ${ANTLR_RUNTIME}/build
6365
RUN cmake .. -D\
6466
ANTLR_JAR_LOCATION=${ANTLR_EXECUTABLE}\
6567
-DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True
66-
RUN make && make install
68+
RUN make -j ${JOBS} && make install
6769

6870
# Build modified PostgreSQL for Babelfish
6971
WORKDIR ${PG_SRC}
@@ -80,11 +82,11 @@ RUN ./configure CFLAGS="-ggdb"\
8082
--with-icu\
8183
--with-openssl
8284

83-
RUN make DESTDIR=${BABELFISH_HOME}/ 2>error.txt && make install
85+
RUN make DESTDIR=${BABELFISH_HOME}/ -j ${JOBS} 2>error.txt && make install
8486

8587
WORKDIR ${PG_SRC}/contrib
8688

87-
RUN make && make install
89+
RUN make -j ${JOBS} && make install
8890

8991
# Compile the ANTLR parser generator
9092
RUN cp /usr/local/lib/libantlr4-runtime.so.${ANTLR4_VERSION}\
@@ -96,41 +98,41 @@ RUN make all
9698

9799
# Compile the contrib modules and build Babelfish
98100
WORKDIR ${PG_SRC}/contrib/babelfishpg_common
99-
RUN make && make PG_CONFIG=${PG_CONFIG} install
101+
RUN make -j ${JOBS} && make PG_CONFIG=${PG_CONFIG} install
100102

101103
WORKDIR ${PG_SRC}/contrib/babelfishpg_money
102-
RUN make && make PG_CONFIG=${PG_CONFIG} install
104+
RUN make -j ${JOBS} && make PG_CONFIG=${PG_CONFIG} install
103105

104106
WORKDIR ${PG_SRC}/contrib/babelfishpg_tds
105-
RUN make && make PG_CONFIG=${PG_CONFIG} install
107+
RUN make -j ${JOBS} && make PG_CONFIG=${PG_CONFIG} install
106108

107109
WORKDIR ${PG_SRC}/contrib/babelfishpg_tsql
108-
RUN make && make PG_CONFIG=${PG_CONFIG} install
110+
RUN make -j ${JOBS} && make PG_CONFIG=${PG_CONFIG} install
109111

110112
# Run stage
111-
FROM ubuntu:20.04
113+
FROM base
112114
ENV DEBIAN_FRONTEND=noninteractive
113115
ENV BABELFISH_HOME=/opt/babelfish
116+
ENV POSTGRES_USER_HOME=/var/lib/babelfish
114117

115118
# Copy binaries to run stage
116119
WORKDIR ${BABELFISH_HOME}
117120
COPY --from=0 ${BABELFISH_HOME} .
118121

119122
# Install runtime dependencies
120123
RUN apt update && apt install -y --no-install-recommends\
121-
libssl1.1 openssl libldap-2.4-2 libxml2 libpam0g uuid libossp-uuid16\
122-
libxslt1.1 libicu66 libpq5 unixodbc
124+
libssl3 openssl libldap-2.5-0 libxml2 libpam0g uuid libossp-uuid16\
125+
libxslt1.1 libicu70 libpq5 unixodbc
123126

124127
# Enable data volume
125-
ENV BABELFISH_DATA=/data/babelfish
126-
RUN mkdir /data
127-
VOLUME /data
128-
RUN mkdir ${BABELFISH_DATA}
128+
ENV BABELFISH_DATA=${POSTGRES_USER_HOME}/data
129+
RUN mkdir -p ${BABELFISH_DATA}
130+
VOLUME ${BABELFISH_DATA}
129131

130132
# Create postgres user
131-
RUN adduser postgres --home ${BABELFISH_DATA}
132-
RUN chown postgres ${BABELFISH_DATA}
133-
RUN chmod 750 ${BABELFISH_DATA}
133+
RUN adduser postgres --home ${POSTGRES_USER_HOME}
134+
RUN chown -R postgres ${BABELFISH_HOME}
135+
RUN chown -R postgres ${POSTGRES_USER_HOME}
134136

135137
# Change to postgres user
136138
USER postgres

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Starting with the `2.3.0` image pushed on Mar 4, 2023, encryption (SSL) support
4949
As a very basic example, to enable encryption with a *self-signed* certificate that *expires in 365 days* and has a *subject of localhost*, in the container's terminal run the following commands:
5050

5151
```sh
52-
cd /data/babelfish
52+
cd /var/lib/babelfish/data
5353
openssl req -new -x509 -days 365 -nodes -text -out server.crt -keyout server.key -subj "/CN=localhost"
5454
chmod og-rwx server.key
5555
echo "ssl = on" >> postgresql.conf
@@ -80,10 +80,13 @@ Assuming Babelfish is hosted on the local machine, using the default settings, a
8080

8181
## Data Volume
8282

83-
Database data is stored in the `/data` volume.
83+
Database data is stored in the `/var/lib/babelfish/data` volume.
8484

8585
## Building Docker Image
8686

87+
> [!IMPORTANT]
88+
> The Dockerfile was changed for `BABEL_5_2_0__PG_17_5`. To build an earlier version, the `before-BABEL_5_2_0__PG_17_5` branch should be used.
89+
8790
To build the Docker image, clone the repository and then run `docker build .`.
8891

8992
To use a different Babelfish version, you can:
@@ -93,6 +96,8 @@ To use a different Babelfish version, you can:
9396

9497
The Babelfish version tags are listed at https://github.com/babelfish-for-postgresql/babelfish-for-postgresql/tags.
9598

99+
100+
96101
## Other Extensions
97102

98103
Adding other extensions is outside of the scope of this project. They may not be able to be used through Babelfish and may cause issues with the Babelfish extensions or not work as expected.

start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
BABELFISH_HOME=/opt/babelfish
3-
BABELFISH_DATA=/data/babelfish
3+
BABELFISH_DATA=/var/lib/babelfish/data
44

55
cd ${BABELFISH_HOME}/bin
66

0 commit comments

Comments
 (0)