|
19 | 19 | # -------------------------------------------------------------------- |
20 | 20 | # Multi-stage Dockerfile for Apache Cloudberry Sandbox Environment |
21 | 21 | # -------------------------------------------------------------------- |
22 | | -# This Dockerfile uses pre-built Apache Cloudberry build images to |
23 | | -# compile and install Cloudberry from the main branch, then creates |
24 | | -# a runtime environment for testing and development. |
| 22 | +# This Dockerfile supports two source modes: |
| 23 | +# - Main branch: clone the latest main from GitHub (CODEBASE_VERSION=main) |
| 24 | +# - Local source: use the repository contents from the Docker build context |
| 25 | +# (CODEBASE_VERSION=local), recommended for developers working from |
| 26 | +# their current checkout. |
| 27 | +# In both modes it compiles and installs Cloudberry, then creates a |
| 28 | +# runtime environment for testing and development. |
25 | 29 | # -------------------------------------------------------------------- |
26 | 30 |
|
27 | 31 | # Build stage: Use pre-built image to compile Cloudberry |
| 32 | +ARG CODEBASE_VERSION=main |
28 | 33 | FROM rockylinux/rockylinux:9.6 AS builder |
| 34 | +ARG CODEBASE_VERSION |
29 | 35 |
|
30 | 36 | # Install build toolchains and development headers (avoid coreutils/curl conflicts on arm64) |
31 | 37 | RUN dnf makecache && \ |
@@ -118,8 +124,20 @@ RUN groupadd -r gpadmin && \ |
118 | 124 | USER gpadmin |
119 | 125 | WORKDIR /home/gpadmin |
120 | 126 |
|
121 | | -# Clone the latest Cloudberry source code |
122 | | -RUN git clone --recurse-submodules --branch main --single-branch --depth=1 https://github.com/apache/cloudberry.git |
| 127 | +# Copy repository contents from build context |
| 128 | +# Note: This COPY always executes regardless of CODEBASE_VERSION due to Docker |
| 129 | +# layer caching behavior. For main branch builds, the copied content will be |
| 130 | +# removed and replaced by a fresh git clone in the RUN step below. This is an |
| 131 | +# acceptable tradeoff to keep the Dockerfile simple and maintainable. |
| 132 | +COPY --chown=gpadmin:gpadmin . /home/gpadmin/cloudberry |
| 133 | + |
| 134 | +# Obtain Cloudberry source code based on build mode |
| 135 | +RUN if [ "${CODEBASE_VERSION}" = "local" ]; then \ |
| 136 | + echo "Using local source from build context"; \ |
| 137 | + else \ |
| 138 | + rm -rf /home/gpadmin/cloudberry && \ |
| 139 | + git clone --recurse-submodules --branch main --single-branch --depth=1 https://github.com/apache/cloudberry.git; \ |
| 140 | + fi |
123 | 141 |
|
124 | 142 | # Build Cloudberry using the official build scripts |
125 | 143 | RUN cd /home/gpadmin/cloudberry && \ |
@@ -188,12 +206,12 @@ COPY --from=builder /usr/local/xerces-c/lib/libxerces-c.so /usr/local/cloudberry |
188 | 206 | COPY --from=builder /usr/local/xerces-c/lib/libxerces-c-3.*.so /usr/local/cloudberry-db/lib/ |
189 | 207 |
|
190 | 208 | # Copy configuration files to their final destinations |
191 | | -COPY ./configs/90-cbdb-limits.conf /etc/security/limits.d/90-cbdb-limits.conf |
192 | | -COPY ./configs/90-cbdb-sysctl.conf /etc/sysctl.d/90-cbdb-sysctl.conf |
193 | | -COPY ./configs/gpinitsystem_singlenode /tmp/gpinitsystem_singlenode |
194 | | -COPY ./configs/gpinitsystem_multinode /tmp/gpinitsystem_multinode |
195 | | -COPY ./configs/multinode-gpinit-hosts /tmp/multinode-gpinit-hosts |
196 | | -COPY ./configs/init_system.sh /tmp/init_system.sh |
| 209 | +COPY devops/sandbox/configs/90-cbdb-limits.conf /etc/security/limits.d/90-cbdb-limits.conf |
| 210 | +COPY devops/sandbox/configs/90-cbdb-sysctl.conf /etc/sysctl.d/90-cbdb-sysctl.conf |
| 211 | +COPY devops/sandbox/configs/gpinitsystem_singlenode /tmp/gpinitsystem_singlenode |
| 212 | +COPY devops/sandbox/configs/gpinitsystem_multinode /tmp/gpinitsystem_multinode |
| 213 | +COPY devops/sandbox/configs/multinode-gpinit-hosts /tmp/multinode-gpinit-hosts |
| 214 | +COPY devops/sandbox/configs/init_system.sh /tmp/init_system.sh |
197 | 215 |
|
198 | 216 | # Runtime configuration |
199 | 217 | RUN echo "cdw" > /tmp/gpdb-hosts && \ |
|
0 commit comments