|
| 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"] |
0 commit comments