Skip to content

Commit f6f53b9

Browse files
committed
Add Rocky9 Dockerfile and docs
1 parent 7e867f6 commit f6f53b9

File tree

3 files changed

+513
-0
lines changed

3 files changed

+513
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# --------------------------------------------------------------------
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# --------------------------------------------------------------------
17+
# Dockerfile for Apache Cloudberry (Incubating) - Production Build
18+
# --------------------------------------------------------------------
19+
# Multi-stage build optimized for production deployment
20+
# Builds Cloudberry from source using official development environment
21+
# --------------------------------------------------------------------
22+
23+
# --------------------------------------------------------------------
24+
# Build stage: Use official Cloudberry development image
25+
# --------------------------------------------------------------------
26+
ARG BUILDER_IMAGE=apache/incubator-cloudberry:cbdb-build-rocky9-latest
27+
FROM ${BUILDER_IMAGE} AS builder
28+
29+
# Copy source code
30+
COPY --chown=gpadmin:gpadmin . /home/gpadmin/cloudberry
31+
32+
# Build Cloudberry using official build scripts
33+
USER gpadmin
34+
WORKDIR /home/gpadmin/cloudberry
35+
36+
RUN sudo dnf install -y --enablerepo=crb liburing-devel && \
37+
export SRC_DIR=/home/gpadmin/cloudberry && \
38+
export BUILD_DESTINATION=/usr/local/cloudberry-db && \
39+
mkdir -p ${SRC_DIR}/build-logs && \
40+
./devops/build/automation/cloudberry/scripts/configure-cloudberry.sh && \
41+
./devops/build/automation/cloudberry/scripts/build-cloudberry.sh
42+
43+
# --------------------------------------------------------------------
44+
# Runtime stage: Minimal production image
45+
# --------------------------------------------------------------------
46+
FROM rockylinux/rockylinux:9.6
47+
48+
# Set locale environment
49+
ENV LANG=en_US.UTF-8
50+
ENV LC_ALL=en_US.UTF-8
51+
52+
# Cloudberry environment variables
53+
ENV GPHOME=/usr/local/cloudberry-db
54+
ENV PATH=$GPHOME/bin:$PATH
55+
ENV LD_LIBRARY_PATH=$GPHOME/lib:$LD_LIBRARY_PATH
56+
ENV COORDINATOR_DATA_DIRECTORY=/data0/database/coordinator/gpseg-1
57+
58+
# Runtime dependencies (keep aligned with devops/sandbox/Dockerfile.*.rockylinux9 where possible)
59+
# Note: do NOT install libcurl here to avoid rocky9 libcurl-minimal conflicts.
60+
RUN dnf -y install \
61+
openssh-server openssh-clients \
62+
sudo shadow-utils \
63+
bash procps-ng \
64+
ca-certificates \
65+
python3 \
66+
apr \
67+
bzip2-libs \
68+
krb5-libs \
69+
libevent \
70+
libicu \
71+
libuuid \
72+
libxml2 \
73+
libyaml \
74+
libzstd \
75+
lz4 \
76+
ncurses \
77+
openldap \
78+
openssl \
79+
pam \
80+
pcre2 \
81+
perl \
82+
protobuf \
83+
readline \
84+
zlib \
85+
glibc-langpack-en \
86+
libuv \
87+
liburing \
88+
iproute \
89+
net-tools \
90+
which \
91+
rsync \
92+
keyutils \
93+
libstdc++ && \
94+
dnf clean all && rm -rf /var/cache/dnf
95+
96+
# Set locale and create gpadmin user
97+
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
98+
/usr/sbin/groupadd -r gpadmin && \
99+
/usr/sbin/useradd -m -r -g gpadmin gpadmin && \
100+
printf "Defaults:gpadmin !requiretty\ngpadmin ALL=(ALL) NOPASSWD: ALL\n" > /etc/sudoers.d/90-gpadmin && \
101+
chmod 440 /etc/sudoers.d/90-gpadmin && \
102+
echo -e '\n# Add Cloudberry entries\nif [ -f /usr/local/cloudberry-db/cloudberry-env.sh ]; then\n source /usr/local/cloudberry-db/cloudberry-env.sh\nfi' >> /home/gpadmin/.bashrc
103+
104+
# Create required directories with proper permissions
105+
RUN mkdir -p /data0/database/coordinator /data0/database/primary /data0/database/mirror && \
106+
mkdir -p /home/gpadmin/.ssh && \
107+
mkdir -p /run/sshd && \
108+
chown -R gpadmin:gpadmin /data0 /home/gpadmin/.ssh && \
109+
chmod 700 /home/gpadmin/.ssh
110+
111+
# SSH client config (host keys are generated at runtime by the entrypoint)
112+
RUN echo -e "Host *\n StrictHostKeyChecking no\n UserKnownHostsFile ~/.ssh/known_hosts\n ServerAliveInterval 60" > /home/gpadmin/.ssh/config && \
113+
chown gpadmin:gpadmin /home/gpadmin/.ssh/config && \
114+
chmod 600 /home/gpadmin/.ssh/config
115+
116+
# Copy configuration files from sandbox (reusable components)
117+
COPY --chown=gpadmin:gpadmin devops/sandbox/configs/gpinitsystem_singlenode /tmp/gpinitsystem_singlenode
118+
119+
# Reuse sandbox tuning configs (note: sysctls require privileged/sysctl support at runtime)
120+
COPY devops/sandbox/configs/90-cbdb-limits.conf /etc/security/limits.d/90-cbdb-limits.conf
121+
COPY devops/sandbox/configs/90-cbdb-sysctl.conf /etc/sysctl.d/90-cbdb-sysctl.conf
122+
123+
# Copy custom scripts
124+
COPY --chown=gpadmin:gpadmin devops/build/packaging/docker/cloudberry-entrypoint.sh /usr/local/bin/cloudberry-entrypoint.sh
125+
126+
# Set executable permissions
127+
RUN chmod 755 /usr/local/bin/cloudberry-entrypoint.sh /tmp/gpinitsystem_singlenode
128+
129+
# Copy built Cloudberry from builder stage
130+
COPY --from=builder --chown=gpadmin:gpadmin /usr/local/cloudberry-db /usr/local/cloudberry-db
131+
COPY --from=builder --chown=gpadmin:gpadmin /usr/local/xerces-c/lib/libxerces-c.so /usr/local/cloudberry-db/lib/
132+
COPY --from=builder --chown=gpadmin:gpadmin /usr/local/xerces-c/lib/libxerces-c-3.*.so /usr/local/cloudberry-db/lib/
133+
134+
# Expose coordinator port
135+
EXPOSE 5432
136+
137+
# Healthcheck: coordinator readiness (initialization can take a while)
138+
HEALTHCHECK --interval=10s --timeout=5s --start-period=5m --retries=6 \
139+
CMD /usr/local/cloudberry-db/bin/pg_isready -h localhost -p 5432 || exit 1
140+
141+
# Volume for persistent data
142+
VOLUME ["/data0"]
143+
144+
# Set default user
145+
USER gpadmin
146+
147+
# Entrypoint and default command
148+
ENTRYPOINT ["/usr/local/bin/cloudberry-entrypoint.sh"]
149+
CMD ["cloudberry"]
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Apache Cloudberry (Incubating) Docker image (Rocky Linux 9)
2+
3+
This directory contains Docker build definitions for a single-node Apache Cloudberry container image.
4+
5+
## Build
6+
7+
Build from the current source tree (multi-stage build using a pre-built builder image):
8+
9+
```bash
10+
docker build \
11+
-f devops/build/packaging/docker/Dockerfile.rocky9 \
12+
-t apache/cloudberry:dev .
13+
```
14+
15+
Override the builder image (for example, pin to a digest/tag or use a locally-built builder):
16+
17+
```bash
18+
docker build \
19+
-f devops/build/packaging/docker/Dockerfile.rocky9 \
20+
--build-arg BUILDER_IMAGE=apache/incubator-cloudberry:cbdb-build-rocky9-latest \
21+
-t apache/cloudberry:dev .
22+
```
23+
24+
## Run
25+
26+
On first startup the container initializes a single-node cluster under `/data0` and starts it. By default,
27+
host connections use `md5` and require `POSTGRES_PASSWORD` (similar to the official Postgres images).
28+
29+
```bash
30+
docker volume create cloudberry_data
31+
32+
docker run --rm -it \
33+
--name cloudberry-db \
34+
-e POSTGRES_PASSWORD=postgres \
35+
-p 5432:5432 \
36+
-v cloudberry_data:/data0 \
37+
apache/cloudberry:dev
38+
```
39+
40+
Quick sandbox (NOT recommended for production):
41+
42+
```bash
43+
docker run --rm -it \
44+
--name cloudberry-db \
45+
-e POSTGRES_HOST_AUTH_METHOD=trust \
46+
-p 5432:5432 \
47+
apache/cloudberry:dev
48+
```
49+
50+
## Connect / Inspect
51+
52+
From the host:
53+
54+
```bash
55+
PGPASSWORD=postgres psql -h localhost -p 5432 -U gpadmin -d gpadmin
56+
```
57+
58+
From inside the container:
59+
60+
```bash
61+
docker exec -it cloudberry-db bash -lc "source /usr/local/cloudberry-db/cloudberry-env.sh && psql -d gpadmin"
62+
```
63+
64+
Cluster status and logs:
65+
66+
```bash
67+
docker exec cloudberry-db gpstate -s
68+
docker logs cloudberry-db
69+
```
70+
71+
## Notes
72+
73+
- `sshd` is started for internal cluster communication. Port 22 is not exposed by default.
74+
- For better performance, consider raising ulimits:
75+
`--ulimit nofile=524288:524288 --ulimit nproc=131072:131072`.
76+
- Tuning config files are reused from `devops/sandbox/configs/`:
77+
`/etc/security/limits.d/90-cbdb-limits.conf` and `/etc/sysctl.d/90-cbdb-sysctl.conf`.

0 commit comments

Comments
 (0)