Skip to content

Commit 36b56dd

Browse files
authored
Support multi arch (#13)
* Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Clean workspace * repush * modify generate-stackbrew-library.sh * modify generate-stackbrew-library.sh * modify generate-stackbrew-library.sh * modify generate-stackbrew-library.sh * modify generate-stackbrew-library.sh * modify generate-stackbrew-library.sh * modify generate-stackbrew-library.sh * modify generate-stackbrew-library.sh * modify generate-stackbrew-library.sh * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * fix version.json * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Add support for multi-architecture in Dockerfile * Update ci.yml * Update generate-stackbrew-library.sh * Update generate-stackbrew-library.sh * Update generate-stackbrew-library.sh * Update generate-stackbrew-library.sh * Update generate-stackbrew-library.sh * Update Dockerfile * Update generate-stackbrew-library.sh * Update munge.sh * Update Dockerfile * Update generate-stackbrew-library.sh * Support multi-arch * add bookworm feature * add bookworm feature * Create ubi8 * add bookworm feature * add bookworm feature * add bookworm feature * Update verify-templating.yml * add bookworm feature * add bookworm feature * Update verify-templating.yml * Ensure entrypoint is executable. * Update verify-templating.yml * Update verify-templating.yml * Update Dockerfile-redhat.template * support multi atch * Update verify-templating.yml
1 parent cc4844e commit 36b56dd

9 files changed

+786
-6
lines changed

3/bookworm/Dockerfile

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
7+
# Use Debian as the base image
8+
FROM debian:bookworm-slim as builder
9+
10+
# explicitly set user/group IDs
11+
RUN groupadd -g 1000 ivorysql; \
12+
useradd -u 1000 -g ivorysql -d /var/local/ivorysql -s /bin/sh ivorysql; \
13+
mkdir -p /var/local/ivorysql; \
14+
mkdir -p /usr/src/ivorysql; \
15+
mkdir -p /var/lib/ivorysql; \
16+
chown -R ivorysql:ivorysql /var/local/ivorysql; \
17+
chown -R ivorysql:ivorysql /usr/src/ivorysql; \
18+
chown -R ivorysql:ivorysql /var/lib/ivorysql
19+
20+
RUN mkdir /docker-entrypoint-initdb.d
21+
22+
# Set environment variables for IvorySQL
23+
ENV IVORY_MAJOR 3
24+
ENV IVORY_VERSION 3.3
25+
ARG USE_CHINA_MIRROR=false
26+
27+
# Use China mirror if specified
28+
RUN if [ "$USE_CHINA_MIRROR" = "true" ]; then \
29+
sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources ;\
30+
fi
31+
32+
# Update package list and install necessary dependencies
33+
RUN apt-get update
34+
RUN apt-get install -y make \
35+
libreadline-dev \
36+
zlib1g-dev \
37+
libssl-dev \
38+
flex \
39+
wget \
40+
dpkg \
41+
build-essential \
42+
llvm \
43+
llvm-dev \
44+
liblz4-dev \
45+
clang \
46+
libkrb5-dev \
47+
libselinux1-dev \
48+
libxml2-dev \
49+
libsasl2-dev \
50+
libicu-dev \
51+
e2fslibs-dev \
52+
libsepol-dev \
53+
libsystemd-dev \
54+
libxslt1-dev \
55+
libldap2-dev \
56+
libssl-dev \
57+
libpam0g-dev \
58+
uuid-dev \
59+
python3-dev \
60+
libreadline-dev \
61+
tcl-dev \
62+
zlib1g-dev \
63+
perl \
64+
libperl-dev \
65+
perl \
66+
perl-base \
67+
perl-modules \
68+
perl-doc \
69+
m4 \
70+
libc6 \
71+
libbison-dev\
72+
libossp-uuid-dev\
73+
curl
74+
75+
RUN wget https://mirrors.ustc.edu.cn/gnu/bison/bison-3.0.4.tar.gz; \
76+
tar -xzvf bison-3.0.4.tar.gz; \
77+
cd bison-3.0.4 ; \
78+
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c ;\
79+
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h ;\
80+
mkdir build && cd build ;\
81+
../configure ;\
82+
make && make install ;
83+
84+
RUN wget -O ivorysql.tar.gz "https://github.com/IvorySQL/IvorySQL/archive/refs/tags/IvorySQL_$IVORY_VERSION.tar.gz"; \
85+
tar \
86+
--extract \
87+
--file ivorysql.tar.gz \
88+
--directory /usr/src/ivorysql \
89+
--strip-components 1 \
90+
; \
91+
rm ivorysql.tar.gz; \
92+
cd /usr/src/ivorysql; \
93+
./configure \
94+
--prefix=/var/local/ivorysql/ivorysql-$IVORY_MAJOR \
95+
--enable-cassert --enable-debug --enable-rpath --with-tcl \
96+
--with-python --with-gssapi --with-pam --with-ldap \
97+
--with-openssl --with-libedit-preferred --with-uuid=e2fs \
98+
--with-ossp-uuid --with-libxml --with-libxslt --with-perl \
99+
--without-icu \
100+
;\
101+
make && make install;
102+
103+
RUN rm -rf \
104+
/usr/src/ivorysql \
105+
/usr/local/share/doc \
106+
/usr/local/share/man
107+
108+
RUN chown -R ivorysql:ivorysql /var/local/ivorysql/ivorysql-$IVORY_MAJOR
109+
RUN dpkgArch="$(dpkg --print-architecture)"; # amd64 | arm64v8
110+
RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.11/gosu-$dpkgArch"
111+
112+
RUN chmod +x /usr/local/bin/gosu
113+
114+
FROM debian:bookworm-slim
115+
116+
COPY --from=builder /var/local/ivorysql /var/local/ivorysql/
117+
COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu
118+
119+
ENV IVORY_MAJOR 3
120+
ENV IVORY_VERSION 3.3
121+
ARG USE_CHINA_MIRROR=false
122+
RUN mkdir /docker-entrypoint-initdb.d
123+
124+
RUN useradd -u 1000 ivorysql
125+
126+
# Use China mirror if specified
127+
RUN if [ "$USE_CHINA_MIRROR" = "true" ]; then \
128+
sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources ;\
129+
fi
130+
131+
RUN apt-get update && \
132+
apt-get install -y \
133+
liblz4-1 \
134+
liblz4-dev \
135+
libkrb5-dev \
136+
libxslt1-dev \
137+
libldap-common \
138+
libldap-2.5-0 \
139+
libldap2-dev \
140+
libreadline-dev \
141+
libicu-dev && \
142+
apt-get clean
143+
144+
145+
RUN chown -R ivorysql:ivorysql /var/local/ivorysql
146+
RUN chown -R ivorysql:ivorysql /usr/local/bin
147+
148+
ENV PGDATA /var/local/ivorysql/ivorysql-$IVORY_MAJOR/data
149+
150+
# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values)
151+
RUN mkdir -p "$PGDATA" && chown -R ivorysql:ivorysql "$PGDATA" && chmod 1777 "$PGDATA"
152+
RUN mkdir -p /var/run/postgresql && chown -R ivorysql:ivorysql /var/run/postgresql && chmod 3777 /var/run/postgresql
153+
154+
VOLUME ["/var/local/ivorysql/ivorysql-$IVORY_MAJOR/data","/var/local/ivorysql/data"]
155+
156+
ENV PATH $PATH:/var/local/ivorysql/ivorysql-$IVORY_MAJOR/bin
157+
158+
COPY docker-entrypoint.sh docker-ensure-initdb.sh /usr/local/bin/
159+
RUN ln -sT docker-ensure-initdb.sh /usr/local/bin/docker-enforce-initdb.sh
160+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
161+
162+
ENTRYPOINT ["docker-entrypoint.sh"]
163+
164+
STOPSIGNAL SIGINT
165+
166+
EXPOSE 5432 5866 1521
167+
168+
CMD ["postgres"]

3/bookworm/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)