-
Notifications
You must be signed in to change notification settings - Fork 0
/
babelfish-2point1.dockerfile
123 lines (91 loc) · 4.13 KB
/
babelfish-2point1.dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get 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 ca-certificates wget
RUN curl -L https://github.com/babelfish-for-postgresql/babelfish-for-postgresql/releases/download/BABEL_2_1_0__PG_14_3/BABEL_2_1_0__PG_14_3.tar.gz --output /opt/BABEL_2_1_0__PG_14_3.tar.gz \
&& tar -xzvf /opt/BABEL_2_1_0__PG_14_3.tar.gz -C /opt/ \
&& mv /opt/BABEL_2_1_0__PG_14_3 /opt/postgres-babelfish
WORKDIR /opt/postgres-babelfish
ENV JOBS=4 \
BABELFISH_HOME=/opt/babelfish/2.1 \
PG_CONFIG=${BABELFISH_HOME}/bin/pg_config \
PG_SRC=/opt/postgres-babelfish \
ANTLR4_VERSION=4.9.3 \
ANTLR4_JAVA_BIN=/usr/bin/java \
ANTLR4_RUNTIME_LIBRARIES=/usr/include/antlr4-runtime \
ANTLR_EXECUTABLE=/usr/local/lib/antlr-${ANTLR4_VERSION}-complete.jar \
ANTLR_RUNTIME=/opt/antlr4
RUN cp ${PG_SRC}/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-${ANTLR4_VERSION}-complete.jar /usr/local/lib
WORKDIR /opt
RUN curl -L http://www.antlr.org/download/antlr4-cpp-runtime-${ANTLR4_VERSION}-source.zip -o /opt/antlr4-cpp-runtime-${ANTLR4_VERSION}-source.zip \
&& unzip /opt/antlr4-cpp-runtime-${ANTLR4_VERSION}-source.zip -d ${ANTLR_RUNTIME}
WORKDIR ${ANTLR_RUNTIME}
RUN mkdir build && cd build \
&& cmake .. -D ANTLR_JAR_LOCATION=/usr/local/lib/antlr-${ANTLR4_VERSION}-complete.jar -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True \
&& make -j $JOBS \
&& make install
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 \
&& make DESTDIR=${BABELFISH_HOME}/ -j $JOBS 2>error.txt \
&& make install
WORKDIR ${PG_SRC}/contrib
RUN make -j ${JOBS} \
&& make install
RUN export cmake=$(which cmake) \
&& cp /usr/local/lib/libantlr4-runtime.so.${ANTLR4_VERSION} ${BABELFISH_HOME}/lib
WORKDIR ${PG_SRC}/contrib/babelfishpg_tsql/antlr
RUN cmake -Wno-dev . \
&& make all
WORKDIR ${PG_SRC}/contrib
RUN for ext in babelfishpg_common babelfishpg_money babelfishpg_tds babelfishpg_tsql; \
do \
echo "Building ${ext}"; \
cd $ext; \
make -j ${JOBS}; \
make PG_CONFIG=${PG_CONFIG} install; \
cd ..; \
done
RUN mkdir -p /var/lib/babelfish/2.1 \
& adduser postgres --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password \
&& chown -R postgres: /opt/babelfish/ \
&& chown -R postgres: /var/lib/babelfish/ \
&& usermod --home /var/lib/babelfish postgres
ENV BABELFISH_HOME=/opt/babelfish/2.1 \
BABELFISH_DATA=/var/lib/babelfish/2.1/data
RUN mkdir -p "${BABELFISH_DATA}" && chown -R postgres: "${BABELFISH_DATA}" && chmod 777 "${BABELFISH_DATA}"
COPY entrypoint.sh /usr/local/bin/
RUN chown postgres: /usr/local/bin/entrypoint.sh \
&& chmod +x /usr/local/bin/entrypoint.sh
WORKDIR /opt/babelfish/2.1/bin
USER postgres
ENV BABELFISH_HOME=/opt/babelfish/2.1 \
BABELFISH_DATA=/var/lib/babelfish/2.1/data \
PATH="/opt/babelfish/2.1/bin:${PATH}"
# make the sample config easier to munge (and "correct by default")
RUN set -eux; \
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" "${BABELFISH_HOME}/share/postgresql/postgresql.conf.sample"; \
sed -ri "s+#?shared_preload_libraries.*+shared_preload_libraries = 'babelfishpg_tds'+g" "${BABELFISH_HOME}/share/postgresql/postgresql.conf.sample"; \
grep -F "listen_addresses = '*'" "${BABELFISH_HOME}/share/postgresql/postgresql.conf.sample"
STOPSIGNAL SIGINT
EXPOSE 1433
EXPOSE 5432
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["postgres"]