1+ FROM redhat/ubi8:latest as builder
2+
3+ # explicitly set user/group IDs
4+ RUN groupadd -g 1000 ivorysql; \
5+ useradd -u 1000 -g ivorysql -d /var/local/ivorysql -s /bin/sh ivorysql; \
6+ mkdir -p /var/local/ivorysql; \
7+ mkdir -p /usr/src/ivorysql; \
8+ mkdir -p /var/lib/ivorysql; \
9+ chown -R ivorysql:ivorysql /var/local/ivorysql; \
10+ chown -R ivorysql:ivorysql /usr/src/ivorysql; \
11+ chown -R ivorysql:ivorysql /var/lib/ivorysql
12+
13+ RUN mkdir /docker-entrypoint-initdb.d
14+ # install ivorysql 4.6
15+ ENV IVORY_MAJOR 4
16+ ENV IVORY_VERSION 4.6
17+
18+ RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo; \
19+ sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
20+
21+ RUN mkdir -p /usr/src/ivorysql; \
22+ dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm; \
23+ dnf install -y epel-release;\
24+ dnf install -y \
25+ make \
26+ readline-devel \
27+ zlib-devel \
28+ openssl-devel \
29+ flex \
30+ wget \
31+ dpkg; \
32+ dnf groupinstall -y "Development Tools" ;\
33+ dnf install -y \
34+ llvm-toolset llvm-devel lz4 lz4-devel lz4-libs clang-devel \
35+ krb5-devel libselinux-devel libxml2-devel cyrus-sasl-gssapi \
36+ libicu-devel e2fsprogs-devel selinux-policy systemd-devel \
37+ libxslt-devel openldap-devel openssl-devel pam-devel \
38+ libuuid-devel python3-devel readline-devel tcl-devel zlib-devel \
39+ perl perl-devel perl-ExtUtils-Embed;\
40+ dnf install -y --enablerepo=*ower*ools perl-IPC-Run perl-Time-HiRes perl-Test-Simple uuid-devel;\
41+ wget -O ivorysql.tar.gz "https://github.com/IvorySQL/IvorySQL/archive/refs/tags/IvorySQL_$IVORY_VERSION.tar.gz" ; \
42+ tar \
43+ --extract \
44+ --file ivorysql.tar.gz \
45+ --directory /usr/src/ivorysql \
46+ --strip-components 1 \
47+ ; \
48+ rm ivorysql.tar.gz; \
49+ cd /usr/src/ivorysql; \
50+ wget https://repo.almalinux.org/almalinux/8/PowerTools/$(arch)/os/Packages/bison-devel-3.0.4-10.el8.$(arch).rpm; \
51+ dnf install -y bison-devel-3.0.4-10.el8.$(arch).rpm; \
52+ wget https://repo.almalinux.org/almalinux/8/AppStream/$(arch)/os/Packages/bison-3.0.4-10.el8.$(arch).rpm; \
53+ dnf install -y bison-3.0.4-10.el8.$(arch).rpm; \
54+ ./configure \
55+ --prefix=/var/local/ivorysql/ivorysql-$IVORY_MAJOR \
56+ --enable-cassert --enable-debug --enable-rpath --with-tcl \
57+ --with-python --with-gssapi --with-pam --with-ldap \
58+ --with-openssl --with-libedit-preferred --with-uuid=e2fs \
59+ --with-ossp-uuid --with-libxml --with-libxslt --with-perl \
60+ --with-icu \
61+ ; \
62+ make && make install; \
63+ rm -rf \
64+ /usr/src/ivorysql \
65+ /usr/local/share/doc \
66+ /usr/local/share/man
67+
68+ FROM redhat/ubi8:latest
69+
70+ RUN useradd -u 1000 ivorysql
71+
72+ COPY --from=builder --chown=ivorysql:ivorysql /var/local/ivorysql /var/local/ivorysql/
73+
74+ ENV IVORY_MAJOR 4
75+ ENV IVORY_VERSION 4.6
76+
77+ RUN dnf install -y \
78+ lz4 lz4-devel lz4-libs krb5-devel libxslt-devel libicu-devel && dnf -y clean all
79+
80+ # install patroni 4.0.6
81+ env PATRONI_VER 4.0.6
82+
83+ RUN dnf -y install --nodocs \
84+ --setopt=skip_missing_names_on_install=False \
85+ python3-pip \
86+ python3-psutil \
87+ python3-psycopg2 \
88+ && dnf -y clean all
89+
90+ RUN pip3 install --upgrade python-dateutil \
91+ && pip3 install patroni[etcd]=="${PATRONI_VER}"
92+
93+ ENV PGDATA /var/local/ivorysql/ivorysql-$IVORY_MAJOR/data
94+ ENV PATRONICONF /var/local/ivorysql/ivorysql-$IVORY_MAJOR/patroni
95+ # this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values)
96+ RUN mkdir -p "$PGDATA" && chown -R ivorysql:ivorysql "$PGDATA" && chmod 750 "$PGDATA"
97+ RUN mkdir -p "$PATRONICONF" && chown -R ivorysql:ivorysql "$PATRONICONF" && chmod 1777 "$PATRONICONF"
98+
99+ COPY docker-entrypoint.sh /
100+ RUN chmod +x docker-entrypoint.sh
101+
102+ VOLUME $PGDATA $PATRONICONF
103+
104+ ENV PATH $PATH:/var/local/ivorysql/ivorysql-$IVORY_MAJOR/bin
105+
106+ EXPOSE 5432 5866 1521
107+
108+ USER ivorysql
109+
110+ ENTRYPOINT ["/bin/sh" , "/docker-entrypoint.sh" ]
0 commit comments