Skip to content

Commit 0726d7d

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

File tree

3 files changed

+540
-0
lines changed

3 files changed

+540
-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 and timezone
49+
ENV TZ=UTC
50+
ENV LANG=en_US.UTF-8
51+
ENV LC_ALL=en_US.UTF-8
52+
53+
# Cloudberry environment variables
54+
ENV GPHOME=/usr/local/cloudberry-db
55+
ENV PATH=$GPHOME/bin:$PATH
56+
ENV LD_LIBRARY_PATH=$GPHOME/lib:$LD_LIBRARY_PATH
57+
ENV COORDINATOR_DATA_DIRECTORY=/data0/database/coordinator/gpseg-1
58+
59+
# Runtime dependencies (keep aligned with devops/sandbox/Dockerfile.*.rockylinux9 where possible)
60+
# Note: do NOT install libcurl here to avoid rocky9 libcurl-minimal conflicts.
61+
RUN dnf -y install --setopt=install_weak_deps=False \
62+
apr \
63+
bash \
64+
bzip2-libs \
65+
ca-certificates \
66+
glibc-langpack-en \
67+
iproute \
68+
keyutils \
69+
krb5-libs \
70+
libevent \
71+
libicu \
72+
libstdc++ \
73+
liburing \
74+
libuv \
75+
libuuid \
76+
libxml2 \
77+
libyaml \
78+
libzstd \
79+
lz4 \
80+
ncurses \
81+
net-tools \
82+
openldap \
83+
openssh-clients \
84+
openssh-server \
85+
openssl \
86+
pam \
87+
pcre2 \
88+
perl \
89+
procps-ng \
90+
protobuf \
91+
python3 \
92+
readline \
93+
rsync \
94+
shadow-utils \
95+
sudo \
96+
which \
97+
zlib && \
98+
dnf clean all && rm -rf /var/cache/dnf
99+
100+
# Set locale, create gpadmin user, and setup directories & SSH config
101+
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
102+
/usr/sbin/groupadd -r gpadmin && \
103+
/usr/sbin/useradd -m -r -g gpadmin gpadmin && \
104+
printf "Defaults:gpadmin !requiretty\ngpadmin ALL=(ALL) NOPASSWD: ALL\n" > /etc/sudoers.d/90-gpadmin && \
105+
chmod 440 /etc/sudoers.d/90-gpadmin && \
106+
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 && \
107+
mkdir -p /data0/database/coordinator /data0/database/primary /data0/database/mirror && \
108+
mkdir -p /home/gpadmin/.ssh && \
109+
mkdir -p /run/sshd && \
110+
chown -R gpadmin:gpadmin /data0 /home/gpadmin/.ssh && \
111+
chmod 700 /home/gpadmin/.ssh && \
112+
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: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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, host connections use `trust` authentication to facilitate seamless development and testing workflows.
27+
28+
```bash
29+
docker volume create cloudberry_data
30+
31+
docker run --rm -it \
32+
--name cloudberry-db \
33+
-p 5432:5432 \
34+
-v cloudberry_data:/data0 \
35+
apache/cloudberry:dev
36+
```
37+
38+
When run interactively (with `-it` and without `-d`), the container initializes the cluster and immediately drops you into a `psql` prompt.
39+
40+
If you prefer to run it in the background (detached), use the `-d` flag. **Important**: Do not combine `-d` with `-t` or `-it`, otherwise the container will attempt to start the interactive SQL prompt and exit immediately.
41+
42+
```bash
43+
docker run --rm -d \
44+
--name cloudberry-db \
45+
-p 5432:5432 \
46+
-v cloudberry_data:/data0 \
47+
apache/cloudberry:dev
48+
```
49+
50+
If you require production-level security (e.g., password enforcement), simply run the container with `-e POSTGRES_HOST_AUTH_METHOD=md5` and provide a `POSTGRES_PASSWORD`:
51+
52+
```bash
53+
docker run --rm -it \
54+
-d \
55+
--name cloudberry-db \
56+
-e POSTGRES_HOST_AUTH_METHOD=md5 \
57+
-e POSTGRES_PASSWORD=your_secure_password \
58+
-p 5432:5432 \
59+
-v cloudberry_data:/data0 \
60+
apache/cloudberry:dev
61+
```
62+
63+
## Connect / Inspect
64+
65+
From the host (assuming `trust` default or matching passwords):
66+
67+
```bash
68+
psql -h localhost -p 5432 -U gpadmin -d gpadmin
69+
```
70+
71+
From inside the container (environment variables are already globally injected):
72+
73+
```bash
74+
docker exec -it cloudberry-db psql -d postgres
75+
```
76+
77+
Cluster status and logs:
78+
79+
```bash
80+
docker exec cloudberry-db gpstate -s
81+
docker logs cloudberry-db
82+
```
83+
84+
## Notes
85+
86+
- **Timezone:** The container defaults to `UTC` (`TZ=UTC`). To use a different timezone, pass the `TZ` environment variable during run (e.g., `-e TZ=Asia/Shanghai`).
87+
- **Graceful Shutdown:** The entrypoint natively traps `SIGTERM`, `SIGINT`, and `SIGQUIT` to perform a safe `gpstop -a -M fast`. Standard `docker stop <container>` is perfectly safe and ensures data consistency.
88+
- **Internal SSH:** `sshd` is started exclusively for internal cluster communication. Port 22 is not exposed by default.
89+
- **System Limits:** For maximum performance, consider explicitly raising container limits at runtime:
90+
`--ulimit nofile=524288:524288 --ulimit nproc=131072:131072`.
91+
- **Tuning Configs:** Environment system configurations are powerfully reused from `devops/sandbox/configs/`:
92+
`/etc/security/limits.d/90-cbdb-limits.conf` and `/etc/sysctl.d/90-cbdb-sysctl.conf`.

0 commit comments

Comments
 (0)