Skip to content
This repository was archived by the owner on Sep 12, 2025. It is now read-only.

Commit 7f82c00

Browse files
committed
Add initial Dockerfiles, configs, and GitHub workflows for Cloudberry
- Include Dockerfiles for Rocky Linux 8 and 9 based build and test environments - Add test scripts, configuration files, and automation support for containerized builds - Provide necessary scripts for testing and deploying across both supported environments - Add GitHub workflow files for building and testing containers - Add initial Dockerfiles and configs for Cloudberry
1 parent 72e5f06 commit 7f82c00

22 files changed

+2521
-0
lines changed
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# --------------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed
5+
# with this work for additional information regarding copyright
6+
# ownership. The ASF licenses this file to You under the Apache
7+
# License, Version 2.0 (the "License"); you may not use this file
8+
# except in compliance with the License. You may obtain a copy of the
9+
# License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16+
# implied. See the License for the specific language governing
17+
# permissions and limitations under the License.
18+
#
19+
# --------------------------------------------------------------------
20+
#
21+
# Purpose: Builds, tests and pushes Docker images for Apache Cloudberry DB build environments
22+
# Images are built for Rocky Linux 8 and 9, tested with TestInfra, and pushed to DockerHub
23+
#
24+
# Images are tagged with:
25+
# - cbdb-build-rocky8-latest
26+
# - cbdb-build-rocky8-{YYYYMMDD}-{git-short-sha}
27+
# - cbdb-build-rocky9-latest
28+
# - cbdb-build-rocky9-{YYYYMMDD}-{git-short-sha}
29+
#
30+
# Features:
31+
# - Matrix build for multiple platforms
32+
# - Caching strategy for efficient builds
33+
# - Path filtering to only build changed platforms
34+
# - Comprehensive build summary and metadata
35+
# - Container testing with TestInfra
36+
37+
name: docker-cbdb-build-containers
38+
39+
# Trigger on pushes to docker-images branch when relevant paths change
40+
# Also allows manual triggering via GitHub UI
41+
on:
42+
push:
43+
branches:
44+
- main
45+
paths:
46+
- 'images/docker/cbdb/build/rocky8/**'
47+
- 'images/docker/cbdb/build/rocky9/**'
48+
workflow_dispatch: # Manual trigger
49+
50+
# Prevent multiple workflow runs from interfering with each other
51+
concurrency:
52+
group: docker-build-${{ github.ref }}
53+
cancel-in-progress: true
54+
55+
jobs:
56+
build-and-push:
57+
timeout-minutes: 60 # Prevent hanging builds
58+
runs-on: ubuntu-latest
59+
strategy:
60+
matrix:
61+
# Build for both Rocky Linux 8 and 9
62+
platform: ['rocky8', 'rocky9']
63+
64+
steps:
65+
# Checkout repository code
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
69+
# Generate version information for image tags
70+
- name: Set version
71+
id: version
72+
run: |
73+
echo "BUILD_DATE=$(date -u +'%Y%m%d')" >> $GITHUB_OUTPUT
74+
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
75+
76+
# Determine if the current platform's files have changed
77+
- name: Determine if platform changed
78+
id: platform-filter
79+
uses: dorny/paths-filter@v3
80+
with:
81+
filters: |
82+
rocky8:
83+
- 'images/docker/cbdb/build/rocky8/**'
84+
rocky9:
85+
- 'images/docker/cbdb/build/rocky9/**'
86+
87+
# Skip if no changes for current platform
88+
- name: Skip if not relevant
89+
if: ${{ steps.platform-filter.outputs[matrix.platform] != 'true' }}
90+
run: echo "Skipping because the changes do not affect this platform"
91+
92+
# Login to DockerHub for pushing images
93+
- name: Login to Docker Hub
94+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
95+
uses: docker/login-action@v3
96+
with:
97+
username: ${{ secrets.DOCKERHUB_USER }}
98+
password: ${{ secrets.DOCKERHUB_TOKEN }}
99+
100+
# Setup Docker Buildx for efficient builds
101+
- name: Set up Docker Buildx
102+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
103+
uses: docker/setup-buildx-action@v3
104+
with:
105+
buildkitd-flags: --debug
106+
107+
# Build the Docker image locally for testing
108+
- name: Build Docker image for cbdb-build-${{ matrix.platform }}
109+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
110+
uses: docker/build-push-action@v6
111+
with:
112+
context: ./images/docker/cbdb/build/${{ matrix.platform }}
113+
push: false # Don't push yet, we'll test first
114+
load: true # Load into local Docker daemon for testing
115+
# Use caching for faster builds
116+
cache-from: |
117+
type=registry,ref=${{ secrets.DOCKERHUB_USER }}/cbdb-build-${{ matrix.platform }}:latest
118+
type=gha,scope=docker-cbdb-build-${{ matrix.platform }}
119+
cache-to: type=gha,mode=max,scope=docker-cbdb-build-${{ matrix.platform }}
120+
tags: |
121+
cbdb-build-${{ matrix.platform }}:latest
122+
# Add metadata labels for better image tracking
123+
labels: |
124+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
125+
org.opencontainers.image.revision=${{ github.sha }}
126+
org.opencontainers.image.created=${{ steps.version.outputs.BUILD_DATE }}
127+
org.opencontainers.image.version=${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}
128+
129+
# Show available Docker images
130+
- name: List Docker images
131+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
132+
run: docker images
133+
134+
# Run TestInfra tests against the built image
135+
- name: Run Testinfra Tests
136+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
137+
id: test
138+
run: |
139+
docker run -d \
140+
-h cdw \
141+
--name cbdb-build-${{ matrix.platform }}-test \
142+
cbdb-build-${{ matrix.platform }}:latest \
143+
bash \
144+
-c "sleep 30"
145+
docker exec cbdb-build-${{ matrix.platform }}-test pytest \
146+
--cache-clear \
147+
--disable-warnings \
148+
-p no:warnings \
149+
/tests/testinfra/test_cloudberry_db_env.py
150+
151+
# Save test results as artifacts
152+
- name: Save test results
153+
if: always() && steps.platform-filter.outputs[matrix.platform] == 'true'
154+
uses: actions/upload-artifact@v3
155+
with:
156+
name: test-results-${{ matrix.platform }}
157+
path: |
158+
test-results/
159+
retention-days: 7
160+
161+
# Cleanup test container
162+
- name: Remove Test Container
163+
if: always() && steps.platform-filter.outputs[matrix.platform] == 'true'
164+
run: docker rm -f cbdb-build-${{ matrix.platform }}-test
165+
166+
# Push the image to DockerHub if tests passed
167+
- name: Retag and Push Docker image to DockerHub
168+
if: steps.test.outcome == 'success' && steps.platform-filter.outputs[matrix.platform] == 'true'
169+
uses: docker/build-push-action@v6
170+
with:
171+
context: ./images/docker/cbdb/build/${{ matrix.platform }}
172+
push: true
173+
cache-from: |
174+
type=registry,ref=${{ secrets.DOCKERHUB_USER }}/cbdb-build-${{ matrix.platform }}:latest
175+
type=gha,scope=docker-cbdb-build-${{ matrix.platform }}
176+
tags: |
177+
${{ secrets.DOCKERHUB_USER }}/incubator-cloudberry:cbdb-build-${{ matrix.platform }}-latest
178+
${{ secrets.DOCKERHUB_USER }}/incubator-cloudberry:cbdb-build-${{ matrix.platform }}-${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}
179+
labels: |
180+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
181+
org.opencontainers.image.revision=${{ github.sha }}
182+
org.opencontainers.image.created=${{ steps.version.outputs.BUILD_DATE }}
183+
org.opencontainers.image.version=${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}
184+
185+
# Generate build summary
186+
- name: Build Summary
187+
if: always()
188+
run: |
189+
echo "### Build Summary for ${{ matrix.platform }} 🚀" >> $GITHUB_STEP_SUMMARY
190+
echo "" >> $GITHUB_STEP_SUMMARY
191+
192+
echo "#### 🔍 Build Information" >> $GITHUB_STEP_SUMMARY
193+
echo "- **Build Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
194+
echo "- **Platform**: ${{ matrix.platform }}" >> $GITHUB_STEP_SUMMARY
195+
echo "- **Commit SHA**: [\`${{ github.sha }}\`](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})" >> $GITHUB_STEP_SUMMARY
196+
echo "- **Trigger**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
197+
echo "- **Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
198+
echo "- **Build Date**: ${{ steps.version.outputs.BUILD_DATE }}" >> $GITHUB_STEP_SUMMARY
199+
echo "- **Version Tag**: \`${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}\`" >> $GITHUB_STEP_SUMMARY
200+
echo "" >> $GITHUB_STEP_SUMMARY
201+
202+
if [[ "${{ steps.test.outcome }}" == "success" && "${{ steps.platform-filter.outputs[matrix.platform] }}" == "true" ]]; then
203+
echo "#### 🐳 Docker Image" >> $GITHUB_STEP_SUMMARY
204+
echo "- **Repository**: [\`${{ secrets.DOCKERHUB_USER }}/cbdb-build-${{ matrix.platform }}\`](https://hub.docker.com/r/${{ secrets.DOCKERHUB_USER }}/cbdb-build-${{ matrix.platform }})" >> $GITHUB_STEP_SUMMARY
205+
echo "- **Tags Pushed**:" >> $GITHUB_STEP_SUMMARY
206+
echo " - \`latest\`" >> $GITHUB_STEP_SUMMARY
207+
echo " - \`${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}\`" >> $GITHUB_STEP_SUMMARY
208+
echo "" >> $GITHUB_STEP_SUMMARY
209+
210+
echo "#### 📋 Quick Reference" >> $GITHUB_STEP_SUMMARY
211+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
212+
echo "# Pull the image" >> $GITHUB_STEP_SUMMARY
213+
echo "docker pull ${{ secrets.DOCKERHUB_USER }}/cbdb-build-${{ matrix.platform }}:${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}" >> $GITHUB_STEP_SUMMARY
214+
echo "" >> $GITHUB_STEP_SUMMARY
215+
echo "# View image details" >> $GITHUB_STEP_SUMMARY
216+
echo "docker inspect ${{ secrets.DOCKERHUB_USER }}/cbdb-build-${{ matrix.platform }}:${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}" >> $GITHUB_STEP_SUMMARY
217+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
218+
fi
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# --------------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed
5+
# with this work for additional information regarding copyright
6+
# ownership. The ASF licenses this file to You under the Apache
7+
# License, Version 2.0 (the "License"); you may not use this file
8+
# except in compliance with the License. You may obtain a copy of the
9+
# License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16+
# implied. See the License for the specific language governing
17+
# permissions and limitations under the License.
18+
#
19+
# --------------------------------------------------------------------
20+
#
21+
# Purpose: Builds, tests and pushes Docker images for Apache Cloudberry DB test environments
22+
# Images are built for Rocky Linux 8 and 9, tested with TestInfra, and pushed to DockerHub
23+
#
24+
# Images are tagged with:
25+
# - cbdb-test-rocky8-latest
26+
# - cbdb-test-rocky8-{YYYYMMDD}-{git-short-sha}
27+
# - cbdb-test-rocky9-latest
28+
# - cbdb-test-rocky9-{YYYYMMDD}-{git-short-sha}
29+
#
30+
# Features:
31+
# - Matrix build for multiple platforms
32+
# - Caching strategy for efficient builds
33+
# - Path filtering to only build changed platforms
34+
# - Comprehensive build summary and metadata
35+
36+
name: docker-cbdb-test-containers
37+
38+
# Trigger on pushes to docker-images branch when relevant paths change
39+
# Also allows manual triggering via GitHub UI
40+
on:
41+
push:
42+
branches:
43+
- main
44+
paths:
45+
- 'images/docker/cbdb/test/rocky8/**'
46+
- 'images/docker/cbdb/test/rocky9/**'
47+
workflow_dispatch: # Manual trigger
48+
49+
# Prevent multiple workflow runs from interfering with each other
50+
concurrency:
51+
group: docker-test-${{ github.ref }}
52+
cancel-in-progress: true
53+
54+
jobs:
55+
build-and-push:
56+
timeout-minutes: 60 # Prevent hanging builds
57+
runs-on: ubuntu-latest
58+
strategy:
59+
matrix:
60+
# Build for both Rocky Linux 8 and 9
61+
platform: ['rocky8', 'rocky9']
62+
63+
steps:
64+
# Checkout repository code
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
# Generate version information for image tags
69+
- name: Set version
70+
id: version
71+
run: |
72+
echo "BUILD_DATE=$(date -u +'%Y%m%d')" >> $GITHUB_OUTPUT
73+
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
74+
75+
# Determine if the current platform's files have changed
76+
- name: Determine if platform changed
77+
id: platform-filter
78+
uses: dorny/paths-filter@v3
79+
with:
80+
filters: |
81+
rocky8:
82+
- 'images/docker/cbdb/test/rocky8/**'
83+
rocky9:
84+
- 'images/docker/cbdb/test/rocky9/**'
85+
86+
# Skip if no changes for current platform
87+
- name: Skip if not relevant
88+
if: ${{ steps.platform-filter.outputs[matrix.platform] != 'true' }}
89+
run: echo "Skipping because the changes do not affect this platform"
90+
91+
# Login to DockerHub for pushing images
92+
- name: Login to Docker Hub
93+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
94+
uses: docker/login-action@v3
95+
with:
96+
username: ${{ secrets.DOCKERHUB_USER }}
97+
password: ${{ secrets.DOCKERHUB_TOKEN }}
98+
99+
# Setup Docker Buildx for efficient builds
100+
- name: Set up Docker Buildx
101+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
102+
uses: docker/setup-buildx-action@v3
103+
with:
104+
buildkitd-flags: --debug
105+
106+
# Build the Docker image locally for testing
107+
- name: Build Docker image for cbdb-test-${{ matrix.platform }}
108+
if: ${{ steps.platform-filter.outputs[matrix.platform] == 'true' }}
109+
uses: docker/build-push-action@v6
110+
with:
111+
context: ./images/docker/cbdb/test/${{ matrix.platform }}
112+
push: false # Don't push yet, we'll test first
113+
load: true # Load into local Docker daemon for testing
114+
# Use caching for faster builds
115+
cache-from: |
116+
type=registry,ref=${{ secrets.DOCKERHUB_USER }}/cbdb-test-${{ matrix.platform }}:latest
117+
type=gha,scope=docker-cbdb-test-${{ matrix.platform }}
118+
cache-to: type=gha,mode=max,scope=docker-cbdb-test-${{ matrix.platform }}
119+
tags: |
120+
cbdb-test-${{ matrix.platform }}:latest
121+
# Add metadata labels for better image tracking
122+
labels: |
123+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
124+
org.opencontainers.image.revision=${{ github.sha }}
125+
org.opencontainers.image.created=${{ steps.version.outputs.BUILD_DATE }}
126+
org.opencontainers.image.version=${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}
127+
128+
# Push the image to DockerHub if tests passed
129+
- name: Retag and Push Docker image to DockerHub
130+
if: steps.platform-filter.outputs[matrix.platform] == 'true'
131+
uses: docker/build-push-action@v6
132+
with:
133+
context: ./images/docker/cbdb/test/${{ matrix.platform }}
134+
push: true
135+
cache-from: |
136+
type=registry,ref=${{ secrets.DOCKERHUB_USER }}/cbdb-test-${{ matrix.platform }}:latest
137+
type=gha,scope=docker-cbdb-test-${{ matrix.platform }}
138+
tags: |
139+
${{ secrets.DOCKERHUB_USER }}/incubator-cloudberry:cbdb-test-${{ matrix.platform }}-latest
140+
${{ secrets.DOCKERHUB_USER }}/incubator-cloudberry:cbdb-test-${{ matrix.platform }}-${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}
141+
labels: |
142+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
143+
org.opencontainers.image.revision=${{ github.sha }}
144+
org.opencontainers.image.created=${{ steps.version.outputs.BUILD_DATE }}
145+
org.opencontainers.image.version=${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}
146+
147+
# Generate build summary
148+
- name: Build Summary
149+
if: always()
150+
run: |
151+
echo "### Build Summary for ${{ matrix.platform }} 🚀" >> $GITHUB_STEP_SUMMARY
152+
echo "" >> $GITHUB_STEP_SUMMARY
153+
154+
echo "#### 🔍 Build Information" >> $GITHUB_STEP_SUMMARY
155+
echo "- **Build Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
156+
echo "- **Platform**: ${{ matrix.platform }}" >> $GITHUB_STEP_SUMMARY
157+
echo "- **Commit SHA**: [\`${{ github.sha }}\`](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})" >> $GITHUB_STEP_SUMMARY
158+
echo "- **Trigger**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
159+
echo "- **Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
160+
echo "- **Build Date**: ${{ steps.version.outputs.BUILD_DATE }}" >> $GITHUB_STEP_SUMMARY
161+
echo "- **Version Tag**: \`${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}\`" >> $GITHUB_STEP_SUMMARY
162+
echo "" >> $GITHUB_STEP_SUMMARY
163+
164+
if [[ "${{ steps.platform-filter.outputs[matrix.platform] }}" == "true" ]]; then
165+
echo "#### 🐳 Docker Image" >> $GITHUB_STEP_SUMMARY
166+
echo "- **Repository**: [\`${{ secrets.DOCKERHUB_USER }}/cbdb-test-${{ matrix.platform }}\`](https://hub.docker.com/r/${{ secrets.DOCKERHUB_USER }}/cbdb-test-${{ matrix.platform }})" >> $GITHUB_STEP_SUMMARY
167+
echo "- **Tags Pushed**:" >> $GITHUB_STEP_SUMMARY
168+
echo " - \`latest\`" >> $GITHUB_STEP_SUMMARY
169+
echo " - \`${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}\`" >> $GITHUB_STEP_SUMMARY
170+
echo "" >> $GITHUB_STEP_SUMMARY
171+
172+
echo "#### 📋 Quick Reference" >> $GITHUB_STEP_SUMMARY
173+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
174+
echo "# Pull the image" >> $GITHUB_STEP_SUMMARY
175+
echo "docker pull ${{ secrets.DOCKERHUB_USER }}/cbdb-test-${{ matrix.platform }}:${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}" >> $GITHUB_STEP_SUMMARY
176+
echo "" >> $GITHUB_STEP_SUMMARY
177+
echo "# View image details" >> $GITHUB_STEP_SUMMARY
178+
echo "docker inspect ${{ secrets.DOCKERHUB_USER }}/cbdb-test-${{ matrix.platform }}:${{ steps.version.outputs.BUILD_DATE }}-${{ steps.version.outputs.SHA_SHORT }}" >> $GITHUB_STEP_SUMMARY
179+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
180+
fi

0 commit comments

Comments
 (0)