|
| 1 | +FROM redhat/{{ env.variant }}: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 | + |
| 15 | +ENV IVORY_MAJOR {{ env.version }} |
| 16 | +ENV IVORY_VERSION {{ .[env.variant].version }} |
| 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 http://mirror.centos.org/centos/7/os/x86_64/Packages/bison-devel-3.0.4-2.el7.x86_64.rpm; \ |
| 51 | + dnf install -y bison-devel-3.0.4-2.el7.x86_64.rpm; \ |
| 52 | + wget https://www.rpmfind.net/linux/centos/8-stream/AppStream/x86_64/os/Packages/bison-3.0.4-10.el8.x86_64.rpm; \ |
| 53 | + dnf install -y bison-3.0.4-10.el8.x86_64.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 | +RUN chown -R ivorysql:ivorysql /var/local/ivorysql/ivorysql-$IVORY_MAJOR |
| 69 | +RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.11/gosu-amd64" |
| 70 | +RUN chmod +x /usr/local/bin/gosu |
| 71 | + |
| 72 | +FROM redhat/{{ env.variant }}:latest |
| 73 | + |
| 74 | +COPY --from=builder /var/local/ivorysql /var/local/ivorysql/ |
| 75 | +COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu |
| 76 | + |
| 77 | +ENV IVORY_MAJOR {{ env.version}} |
| 78 | +ENV IVORY_VERSION {{ .[env.variant].version }} |
| 79 | + |
| 80 | +RUN mkdir /docker-entrypoint-initdb.d |
| 81 | + |
| 82 | +RUN useradd -u 1000 ivorysql |
| 83 | + |
| 84 | +RUN dnf install -y \ |
| 85 | + lz4 lz4-devel lz4-libs krb5-devel libxslt-devel libicu-devel && dnf -y clean all |
| 86 | + |
| 87 | +RUN chown -R ivorysql:ivorysql /var/local/ivorysql |
| 88 | +RUN chown -R ivorysql:ivorysql /usr/local/bin |
| 89 | + |
| 90 | +ENV PGDATA /var/local/ivorysql/ivorysql-$IVORY_MAJOR/data |
| 91 | +# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) |
| 92 | +RUN mkdir -p "$PGDATA" && chown -R ivorysql:ivorysql "$PGDATA" && chmod 1777 "$PGDATA" |
| 93 | +RUN mkdir -p /var/run/postgresql && chown -R ivorysql:ivorysql /var/run/postgresql && chmod 3777 /var/run/postgresql |
| 94 | + |
| 95 | +VOLUME /var/lib/ivorysql/data |
| 96 | + |
| 97 | +ENV PATH $PATH:/var/local/ivorysql/ivorysql-$IVORY_MAJOR/bin |
| 98 | + |
| 99 | +COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/ |
| 100 | +RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh |
| 101 | + |
| 102 | +ENTRYPOINT ["docker-entrypoint.sh"] |
| 103 | + |
| 104 | +STOPSIGNAL SIGINT |
| 105 | + |
| 106 | +EXPOSE 5432 5866 |
| 107 | + |
| 108 | +CMD ["postgres"] |
0 commit comments