Skip to content

Commit 186076a

Browse files
authored
Add ivorysql 3.1 dockerfile with ubi8 (#1)
* add ivorysql 3.1 dockerfile with ubi8 * fixed volumn error
1 parent 07d450f commit 186076a

File tree

3 files changed

+534
-0
lines changed

3 files changed

+534
-0
lines changed

3/ubi-8/DockerFile

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

3/ubi-8/docker-ensure-initdb.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
#
5+
# This script is intended for three main use cases:
6+
#
7+
# 1. (most importantly) as an example of how to use "docker-entrypoint.sh" to extend/reuse the initialization behavior
8+
#
9+
# 2. ("docker-ensure-initdb.sh") as a Kubernetes "init container" to ensure the provided database directory is initialized; see also "startup probes" for an alternative solution
10+
# (no-op if database is already initialized)
11+
#
12+
# 3. ("docker-enforce-initdb.sh") as part of CI to ensure the database is fully initialized before use
13+
# (error if database is already initialized)
14+
#
15+
16+
source /usr/local/bin/docker-entrypoint.sh
17+
18+
# arguments to this script are assumed to be arguments to the "postgres" server (same as "docker-entrypoint.sh"), and most "docker-entrypoint.sh" functions assume "postgres" is the first argument (see "_main" over there)
19+
if [ "$#" -eq 0 ] || [ "$1" != 'postgres' ]; then
20+
set -- postgres "$@"
21+
fi
22+
23+
# see also "_main" in "docker-entrypoint.sh"
24+
25+
docker_setup_env
26+
# setup data directories and permissions (when run as root)
27+
docker_create_db_directories
28+
if [ "$(id -u)" = '0' ]; then
29+
# then restart script as postgres user
30+
exec su-exec postgres "$BASH_SOURCE" "$@"
31+
fi
32+
33+
# only run initialization on an empty data directory
34+
if [ -z "$DATABASE_ALREADY_EXISTS" ]; then
35+
docker_verify_minimum_env
36+
37+
# check dir permissions to reduce likelihood of half-initialized database
38+
ls /docker-entrypoint-initdb.d/ > /dev/null
39+
40+
docker_init_database_dir
41+
pg_setup_hba_conf "$@"
42+
43+
# PGPASSWORD is required for psql when authentication is required for 'local' connections via pg_hba.conf and is otherwise harmless
44+
# e.g. when '--auth=md5' or '--auth-local=md5' is used in POSTGRES_INITDB_ARGS
45+
export PGPASSWORD="${PGPASSWORD:-$POSTGRES_PASSWORD}"
46+
docker_temp_server_start "$@"
47+
48+
docker_setup_db
49+
docker_process_init_files /docker-entrypoint-initdb.d/*
50+
51+
docker_temp_server_stop
52+
unset PGPASSWORD
53+
else
54+
self="$(basename "$0")"
55+
case "$self" in
56+
docker-ensure-initdb.sh)
57+
echo >&2 "$self: note: database already initialized in '$PGDATA'!"
58+
exit 0
59+
;;
60+
61+
docker-enforce-initdb.sh)
62+
echo >&2 "$self: error: (unexpected) database found in '$PGDATA'!"
63+
exit 1
64+
;;
65+
66+
*)
67+
echo >&2 "$self: error: unknown file name: $self"
68+
exit 99
69+
;;
70+
esac
71+
fi

0 commit comments

Comments
 (0)