17
17
# permissions and limitations under the License.
18
18
#
19
19
# --------------------------------------------------------------------
20
- FROM rockylinux/rockylinux:9
21
-
22
- ARG CODEBASE_VERSION_VAR=${CODEBASE_VERSION_VAR}
23
- ARG TIMEZONE_VAR="America/Los_Angeles"
20
+ # Multi-stage Dockerfile for Apache Cloudberry Sandbox Environment
21
+ # --------------------------------------------------------------------
22
+ # This Dockerfile uses pre-built Apache Cloudberry build images to
23
+ # compile and install a specific release version of Cloudberry, then
24
+ # creates a runtime environment for testing and development.
25
+ # --------------------------------------------------------------------
24
26
25
- ENV container=docker
26
- ENV MULTINODE=false
27
+ # Build stage: Use pre-built image to compile Cloudberry
28
+ FROM apache/incubator-cloudberry:cbdb-build-rocky9-latest as builder
27
29
28
- RUN dnf update -y && \
29
- dnf install -y systemd \
30
- systemd-libs && \
31
- dnf clean all
30
+ ARG CODEBASE_VERSION_VAR=${CODEBASE_VERSION_VAR}
32
31
33
- # Clean up unnecessary systemd units
34
- RUN [ -d /lib/systemd/system/sysinit.target.wants ] && find /lib/systemd/system/sysinit.target.wants/ -type l -not -name 'systemd-tmpfiles-setup.service' -delete || echo "Directory /lib/systemd/system/sysinit.target.wants does not exist" && \
35
- [ -d /lib/systemd/system/multi-user.target.wants ] && find /lib/systemd/system/multi-user.target.wants/ -type l -delete || echo "Directory /lib/systemd/system/multi-user.target.wants does not exist" && \
36
- find /etc/systemd/system/*.wants/ -type l -delete || echo "Directory /etc/systemd/system/*.wants does not exist" && \
37
- [ -d /lib/systemd/system/local-fs.target.wants ] && find /lib/systemd/system/local-fs.target.wants/ -type l -delete || echo "Directory /lib/systemd/system/local-fs.target.wants does not exist" && \
38
- [ -d /lib/systemd/system/sockets.target.wants ] && find /lib/systemd/system/sockets.target.wants/ -type l -not -name '*udev*' -delete || echo "Directory /lib/systemd/system/sockets.target.wants does not exist" && \
39
- [ -d /lib/systemd/system/basic.target.wants ] && find /lib/systemd/system/basic.target.wants/ -type l -delete || echo "Directory /lib/systemd/system/basic.target.wants does not exist" && \
40
- [ -d /lib/systemd/system/anaconda.target.wants ] && find /lib/systemd/system/anaconda.target.wants/ -type l -delete || echo "Directory /lib/systemd/system/anaconda.target.wants does not exist"
32
+ # Download and extract the specified release version
33
+ RUN wget -O /tmp/cloudberry-${CODEBASE_VERSION_VAR}.zip https://github.com/apache/cloudberry/archive/refs/tags/${CODEBASE_VERSION_VAR}.zip && \
34
+ cd /tmp/ && \
35
+ unzip /tmp/cloudberry-${CODEBASE_VERSION_VAR}.zip && \
36
+ mv /tmp/cloudberry-${CODEBASE_VERSION_VAR} /tmp/cloudberry && \
37
+ rm -f /tmp/cloudberry-${CODEBASE_VERSION_VAR}.zip
41
38
42
- COPY ./configs/* /tmp/
39
+ # Copy build scripts into the container
40
+ COPY devops/build/automation/cloudberry/scripts /tmp/build-scripts
43
41
44
- RUN echo root:cbdb@123 | chpasswd && \
45
- dnf makecache && \
46
- dnf install -y yum-utils \
47
- epel-release \
48
- git && \
49
- yum-config-manager --disable epel-cisco-openh264 && \
50
- dnf makecache && \
51
- yum-config-manager --disable epel && \
52
- dnf install -y --enablerepo=epel \
53
- the_silver_searcher \
54
- bat \
55
- htop && \
56
- dnf install -y bison \
57
- cmake3 \
58
- ed \
59
- flex \
60
- gcc \
61
- gcc-c++ \
62
- glibc-langpack-en \
63
- go \
64
- initscripts \
65
- iproute \
66
- less \
67
- m4 \
68
- net-tools \
69
- openssh-clients \
70
- openssh-server \
71
- passwd \
72
- perl \
73
- rsync \
74
- sudo \
75
- tar \
76
- unzip \
77
- util-linux-ng \
78
- wget \
79
- sshpass \
80
- which && \
81
- dnf install -y apr-devel \
82
- bzip2-devel \
83
- krb5-devel \
84
- libcurl-devel \
85
- libevent-devel \
86
- libxml2-devel \
87
- libzstd-devel \
88
- openldap-devel \
89
- openssl-devel \
90
- pam-devel \
91
- perl-ExtUtils-Embed \
92
- perl-Test-Simple \
93
- perl-core \
94
- python3-devel \
95
- readline-devel \
96
- zlib-devel && \
97
- dnf install -y --enablerepo=crb \
98
- libuv-devel \
99
- libyaml-devel \
100
- perl-IPC-Run && \
101
- dnf install -y --enablerepo=epel \
102
- xerces-c-devel
42
+ # Build Cloudberry using the official build scripts
43
+ RUN cd /tmp/cloudberry && \
44
+ export SRC_DIR=/tmp/cloudberry && \
45
+ export BUILD_DESTINATION=/usr/local/cloudberry-db && \
46
+ /tmp/build-scripts/configure-cloudberry.sh && \
47
+ /tmp/build-scripts/build-cloudberry.sh
103
48
104
- RUN cp /tmp/90-cbdb-sysctl.conf /etc/sysctl.conf && \
105
- cp /tmp/90-cbdb-limits.conf /etc/security/limits.d/90-cbdb-limits.conf && \
106
- cat /usr/share/zoneinfo/${TIMEZONE_VAR} > /etc/localtime && \
107
- echo "cdw" > /tmp/gpdb-hosts && \
108
- echo "/usr/local/lib" >> /etc/ld.so.conf && \
109
- echo "/usr/local/lib64" >> /etc/ld.so.conf && \
110
- ldconfig && \
111
- chmod 777 /tmp/gpinitsystem_singlenode && \
112
- chmod 777 /tmp/init_system.sh && \
113
- hostname > ~/orig_hostname && \
114
- /usr/sbin/groupadd gpadmin && \
115
- /usr/sbin/useradd gpadmin -g gpadmin -G wheel && \
116
- setcap cap_net_raw+ep /usr/bin/ping && \
117
- echo "cbdb@123"|passwd --stdin gpadmin && \
118
- echo "gpadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
119
- echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
120
- echo "export COORDINATOR_DATA_DIRECTORY=/data0/database/coordinator/gpseg-1" >> /home/gpadmin/.bashrc && \
121
- echo "source /usr/local/cloudberry-db/greenplum_path.sh" >> /home/gpadmin/.bashrc && \
122
- mkdir -p /data0/database/coordinator /data0/database/primary /data0/database/mirror && \
123
- chown -R gpadmin:gpadmin /data0 && \
124
- ssh-keygen -A && \
125
- echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
49
+ # Runtime stage: Use the same base image for runtime environment
50
+ FROM apache/incubator-cloudberry:cbdb-build-rocky9-latest
126
51
127
- RUN wget -O /tmp/cloudberry-${CODEBASE_VERSION_VAR}.zip https://github.com/apache/cloudberry/archive/refs/tags/${CODEBASE_VERSION_VAR}.zip && \
128
- cd /tmp/ && \
129
- unzip /tmp/cloudberry-${CODEBASE_VERSION_VAR}.zip && \
130
- mv /tmp/cloudberry-${CODEBASE_VERSION_VAR} /tmp/cloudberry && \
131
- rm -f /tmp/cloudberry-${CODEBASE_VERSION_VAR}.zip
52
+ ARG CODEBASE_VERSION_VAR=${CODEBASE_VERSION_VAR}
132
53
133
- RUN cd /tmp/cloudberry && \
134
- ./configure --prefix=/usr/local/cloudberry-db \
135
- --enable-cassert \
136
- --enable-debug-extensions \
137
- --enable-ic-proxy \
138
- --enable-mapreduce \
139
- --enable-orafce \
140
- --enable-orca \
141
- --enable-pxf \
142
- --enable-tap-tests \
143
- --with-gssapi \
144
- --with-ldap \
145
- --with-libxml \
146
- --with-openssl \
147
- --with-pam \
148
- --with-perl \
149
- --with-pgport=5432 \
150
- --with-python \
151
- --with-pythonsrc-ext
54
+ # Environment variables (only those not already set in base image)
55
+ ENV MULTINODE=false
152
56
153
- RUN cd /tmp/cloudberry && \
154
- make -j$(nproc) && \
155
- make install
57
+ # Copy built Cloudberry from builder stage
58
+ COPY --from=builder /usr/local/cloudberry-db /usr/local/cloudberry-db
156
59
157
- RUN cd /tmp/cloudberry/contrib && \
158
- make -j$(nproc) && \
159
- make install
60
+ # Runtime configuration (only what's needed beyond base image)
61
+ RUN echo root:cbdb@123 | chpasswd && \
62
+ cp ./configs/90-cbdb-sysctl.conf /etc/sysctl.conf && \
63
+ echo "cdw" > /tmp/gpdb-hosts && \
64
+ chmod 777 ./configs/gpinitsystem_singlenode && \
65
+ chmod 777 ./configs/init_system.sh && \
66
+ hostname > ~/orig_hostname && \
67
+ echo "export COORDINATOR_DATA_DIRECTORY=/data0/database/coordinator/gpseg-1" >> /home/gpadmin/.bashrc && \
68
+ echo "source /usr/local/cloudberry-db/greenplum_path.sh" >> /home/gpadmin/.bashrc && \
69
+ mkdir -p /data0/database/coordinator /data0/database/primary /data0/database/mirror && \
70
+ chown -R gpadmin:gpadmin /data0
160
71
161
72
# ----------------------------------------------------------------------
162
73
# Set the Default User and Command
@@ -167,10 +78,9 @@ RUN cd /tmp/cloudberry/contrib && \
167
78
# testing and functional verification.
168
79
# ----------------------------------------------------------------------
169
80
USER gpadmin
170
- ENV USER=gpadmin
171
81
WORKDIR /home/gpadmin
172
82
173
83
EXPOSE 5432 22
174
84
175
85
VOLUME [ "/sys/fs/cgroup" ]
176
- CMD ["bash","-c","/tmp /init_system.sh"]
86
+ CMD ["bash","-c","./configs /init_system.sh"]
0 commit comments