Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions devops/sandbox/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CODEBASE_VERSION=2.0.0
OS_VERSION=rockylinux9
95 changes: 95 additions & 0 deletions devops/sandbox/Dockerfile.RELEASE.rockylinux9
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# --------------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to You under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# --------------------------------------------------------------------
# Multi-stage Dockerfile for Apache Cloudberry Sandbox Environment
# --------------------------------------------------------------------
# This Dockerfile uses pre-built Apache Cloudberry build images to
# compile and install a specific release version of Cloudberry, then
# creates a runtime environment for testing and development.
# --------------------------------------------------------------------

# Build stage: Use pre-built image to compile Cloudberry
FROM apache/incubator-cloudberry:cbdb-build-rocky9-latest AS builder

ARG CODEBASE_VERSION_VAR=${CODEBASE_VERSION_VAR}

# Switch to gpadmin user
USER gpadmin
WORKDIR /home/gpadmin

# Download and extract the specified release version
RUN wget -O /home/gpadmin/cloudberry-${CODEBASE_VERSION_VAR}.zip https://github.com/apache/cloudberry/archive/refs/tags/${CODEBASE_VERSION_VAR}.zip && \
unzip /home/gpadmin/cloudberry-${CODEBASE_VERSION_VAR}.zip && \
mv /home/gpadmin/cloudberry-${CODEBASE_VERSION_VAR} /home/gpadmin/cloudberry && \
rm -f /home/gpadmin/cloudberry-${CODEBASE_VERSION_VAR}.zip

# Build Cloudberry using the official build scripts
RUN cd /home/gpadmin/cloudberry && \
export SRC_DIR=/home/gpadmin/cloudberry && \
mkdir -p ${SRC_DIR}/build-logs && \
./devops/build/automation/cloudberry/scripts/configure-cloudberry.sh && \
./devops/build/automation/cloudberry/scripts/build-cloudberry.sh

# Runtime stage: Use the same base image for runtime environment
FROM apache/incubator-cloudberry:cbdb-build-rocky9-latest

ARG CODEBASE_VERSION_VAR=${CODEBASE_VERSION_VAR}

# Environment variables (only those not already set in base image)
ENV MULTINODE=false

# Copy built Cloudberry from builder stage
COPY --from=builder /usr/local/cloudberry-db /usr/local/cloudberry-db

# Copy configuration files to their final destinations
COPY ./configs/90-cbdb-limits.conf /etc/security/limits.d/90-cbdb-limits.conf
COPY ./configs/90-cbdb-sysctl.conf /etc/sysctl.d/90-cbdb-sysctl.conf
COPY ./configs/gpinitsystem_singlenode /tmp/gpinitsystem_singlenode
COPY ./configs/gpinitsystem_multinode /tmp/gpinitsystem_multinode
COPY ./configs/multinode-gpinit-hosts /tmp/multinode-gpinit-hosts
COPY ./configs/init_system.sh /tmp/init_system.sh

# Runtime configuration (only what's needed beyond base image)
RUN echo root:cbdb@123 | chpasswd && \
sudo sysctl -p /etc/sysctl.d/90-cbdb-sysctl.conf || true && \
echo "cdw" > /tmp/gpdb-hosts && \
sudo chmod 755 /tmp/gpinitsystem_singlenode && \
sudo chmod 755 /tmp/gpinitsystem_multinode && \
sudo chmod 755 /tmp/init_system.sh && \
hostname > ~/orig_hostname && \
echo "export COORDINATOR_DATA_DIRECTORY=/data0/database/coordinator/gpseg-1" >> /home/gpadmin/.bashrc && \
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 && \
sudo mkdir -p /data0/database/coordinator /data0/database/primary /data0/database/mirror && \
sudo chown -R gpadmin:gpadmin /data0

# ----------------------------------------------------------------------
# Set the Default User and Command
# ----------------------------------------------------------------------
# The default user is set to 'gpadmin', and the container starts by
# running the init_system.sh script. This container serves as a base
# environment, and the Apache Cloudberry RPM can be installed for
# testing and functional verification.
# ----------------------------------------------------------------------
USER gpadmin
WORKDIR /home/gpadmin

EXPOSE 5432 22

VOLUME [ "/sys/fs/cgroup" ]
CMD ["bash","-c","/tmp/init_system.sh"]
119 changes: 119 additions & 0 deletions devops/sandbox/Dockerfile.main.rockylinux9
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# --------------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to You under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# --------------------------------------------------------------------
# Multi-stage Dockerfile for Apache Cloudberry Sandbox Environment
# --------------------------------------------------------------------
# This Dockerfile uses pre-built Apache Cloudberry build images to
# compile and install Cloudberry from the main branch, then creates
# a runtime environment for testing and development.
# --------------------------------------------------------------------

# Build stage: Use pre-built image to compile Cloudberry
FROM apache/incubator-cloudberry:cbdb-build-rocky9-latest AS builder

# Switch to gpadmin user
USER gpadmin
WORKDIR /home/gpadmin

# Clone the latest Cloudberry source code
RUN git clone --recurse-submodules --branch main --single-branch --depth=1 https://github.com/apache/cloudberry.git

# Build Cloudberry using the official build scripts
RUN cd /home/gpadmin/cloudberry && \
export SRC_DIR=/home/gpadmin/cloudberry && \
mkdir -p ${SRC_DIR}/build-logs && \
./devops/build/automation/cloudberry/scripts/configure-cloudberry.sh && \
./devops/build/automation/cloudberry/scripts/build-cloudberry.sh

# --------------------------------------------------------------------
# Runtime stage: Switch to a slimmer base image (Rocky Linux 9)
# --------------------------------------------------------------------
FROM rockylinux/rockylinux:9

# Install required runtime dependencies, SSH server, sudo, and tools
# Note: Use dnf on Rocky Linux 9
RUN dnf -y update && \
dnf -y install \
openssh-server openssh-clients \
sudo shadow-utils \
bash procps-ng iproute iputils \
net-tools which wget \
tar gzip unzip findutils hostname \
ca-certificates \
python3 perl \
libevent libxml2 libyaml zlib \
krb5-libs openssl readline \
bzip2 xz ncurses rsync glibc-langpack-en libuv libicu && \
dnf clean all && rm -rf /var/cache/dnf

# Create gpadmin user and group, grant passwordless sudo
RUN groupadd -r gpadmin && \
useradd -m -r -g gpadmin -s /bin/bash gpadmin && \
echo "gpadmin ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/gpadmin && \
chmod 440 /etc/sudoers.d/gpadmin

# Prepare SSH daemon: generate host keys and ensure runtime dir
RUN ssh-keygen -A && mkdir -p /run/sshd

# Copy built Cloudberry from builder stage
COPY --from=builder /usr/local/cloudberry-db /usr/local/cloudberry-db
# Copy ABI-matched runtime libraries from builder to avoid version mismatch
COPY --from=builder /usr/lib64/libprotobuf* /usr/lib64/
COPY --from=builder /usr/lib64/libuv* /usr/lib64/
# Ensure dynamic linker sees Cloudberry and copied libs
RUN echo '/usr/local/cloudberry-db/lib' > /etc/ld.so.conf.d/cloudberry.conf && ldconfig
# Copy ABI-matched runtime libraries from builder to avoid version mismatch
COPY --from=builder /usr/lib64/libprotobuf* /usr/lib64/
COPY --from=builder /usr/lib64/libuv* /usr/lib64/
# Ensure dynamic linker sees Cloudberry and copied libs
RUN echo '/usr/local/cloudberry-db/lib' > /etc/ld.so.conf.d/cloudberry.conf && ldconfig

# Copy configuration files to their final destinations
COPY ./configs/90-cbdb-limits.conf /etc/security/limits.d/90-cbdb-limits.conf
COPY ./configs/90-cbdb-sysctl.conf /etc/sysctl.d/90-cbdb-sysctl.conf
COPY ./configs/gpinitsystem_singlenode /tmp/gpinitsystem_singlenode
COPY ./configs/gpinitsystem_multinode /tmp/gpinitsystem_multinode
COPY ./configs/multinode-gpinit-hosts /tmp/multinode-gpinit-hosts
COPY ./configs/init_system.sh /tmp/init_system.sh

# Runtime configuration
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
RUN sudo sysctl -p /etc/sysctl.d/90-cbdb-sysctl.conf || true && \
echo "cdw" > /tmp/gpdb-hosts && \
sudo chmod 755 /tmp/gpinitsystem_singlenode && \
sudo chmod 755 /tmp/gpinitsystem_multinode && \
sudo chmod 755 /tmp/init_system.sh && \
mkdir -p /opt/cbdb/cluster-ssh && \
chown gpadmin:gpadmin /opt/cbdb/cluster-ssh && \
mkdir -p /data0/database/coordinator /data0/database/primary /data0/database/mirror && \
chown -R gpadmin:gpadmin /data0 && \
echo "export COORDINATOR_DATA_DIRECTORY=/data0/database/coordinator/gpseg-1" >> /home/gpadmin/.bashrc && \
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

# Set default user and working directory
USER gpadmin
WORKDIR /home/gpadmin

EXPOSE 5432 22

# cgroup mount (provided by compose/run)
VOLUME [ "/sys/fs/cgroup" ]

# Start the container by running the initialization script
CMD ["bash","-c","/tmp/init_system.sh"]
Loading
Loading