Skip to content

Commit bb94c9d

Browse files
committed
Enhance Docker builds with better Dockerfile discovery and use fork names for images
1 parent f566aa7 commit bb94c9d

File tree

1 file changed

+84
-47
lines changed

1 file changed

+84
-47
lines changed

.github/workflows/biogears-complete-pipeline.yml

Lines changed: 84 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ jobs:
2323
with:
2424
fetch-depth: 0
2525

26+
- name: Debug repository structure
27+
run: |
28+
echo "Checking repository structure..."
29+
echo "Root directory:"
30+
ls -la
31+
echo "Docker directory structure (if exists):"
32+
find . -name "Dockerfile" | sort
33+
echo "Docker directory contents (if exists):"
34+
[ -d "docker" ] && ls -la docker/ || echo "No docker directory found"
35+
echo "Checking subdirectories for Docker files:"
36+
for dir in */; do
37+
echo "Contents of $dir:"
38+
ls -la "$dir" || echo "Failed to list $dir"
39+
if [ -d "$dir/docker" ]; then
40+
echo "Docker directory in $dir:"
41+
ls -la "$dir/docker"
42+
fi
43+
done
44+
2645
- name: Set up Docker Buildx
2746
uses: docker/setup-buildx-action@v2
2847

@@ -35,67 +54,85 @@ jobs:
3554

3655
- name: Build External Base Image
3756
run: |
38-
# Build the external dependencies image first
39-
echo "Building biogears-external image..."
57+
# Debug what Docker files exist
58+
echo "Looking for external Dockerfile..."
59+
EXTERNAL_DOCKERFILE=$(find . -name "Dockerfile" -path "*/external/*" | head -n 1)
4060
41-
docker build -t ghcr.io/${{ github.repository_owner }}/biogears-external:latest --progress=plain -f docker/external/Dockerfile docker/external
61+
if [ -z "$EXTERNAL_DOCKERFILE" ]; then
62+
echo "No external Dockerfile found, looking for any Dockerfile..."
63+
EXTERNAL_DOCKERFILE=$(find . -name "Dockerfile" | grep -v "context" | head -n 1)
64+
65+
if [ -z "$EXTERNAL_DOCKERFILE" ]; then
66+
echo "ERROR: No Dockerfile found for external dependencies"
67+
exit 1
68+
fi
69+
fi
70+
71+
echo "Using Dockerfile at: $EXTERNAL_DOCKERFILE"
72+
DOCKERFILE_DIR=$(dirname "$EXTERNAL_DOCKERFILE")
73+
74+
# Build the external dependencies image
75+
echo "Building biogears-external image..."
76+
docker build -t ghcr.io/${{ github.repository_owner }}/biogears-hari-external:latest \
77+
--progress=plain \
78+
-f "$EXTERNAL_DOCKERFILE" "$DOCKERFILE_DIR"
4279
4380
# Tag with date-based version
4481
SHORT_SHA="${{ github.sha }}"
4582
DATE_VERSION="$(date +%Y%m%d)-${SHORT_SHA:0:8}"
46-
docker tag ghcr.io/${{ github.repository_owner }}/biogears-external:latest ghcr.io/${{ github.repository_owner }}/biogears-external:${DATE_VERSION}
83+
docker tag ghcr.io/${{ github.repository_owner }}/biogears-hari-external:latest ghcr.io/${{ github.repository_owner }}/biogears-hari-external:${DATE_VERSION}
4784
4885
# Get image digest
49-
EXTERNAL_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository_owner }}/biogears-external:latest | cut -d'@' -f2 || docker images --no-trunc --quiet ghcr.io/${{ github.repository_owner }}/biogears-external:latest)
86+
EXTERNAL_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository_owner }}/biogears-hari-external:latest 2>/dev/null || docker images --no-trunc --quiet ghcr.io/${{ github.repository_owner }}/biogears-hari-external:latest)
5087
echo "EXTERNAL_DIGEST=$EXTERNAL_DIGEST" > image-digests.txt
5188
echo "EXTERNAL_VERSION=$DATE_VERSION" >> image-digests.txt
89+
echo "EXTERNAL_DOCKERFILE=$EXTERNAL_DOCKERFILE" >> image-digests.txt
5290
echo "External image digest: $EXTERNAL_DIGEST"
5391
5492
- name: Build BioGears with Docker
5593
run: |
56-
# Build the BioGears builder image
57-
echo "Building biogears-builder image..."
94+
source image-digests.txt
5895
59-
if [ -f "docker/release/Dockerfile" ]; then
60-
echo "Building with docker/release/Dockerfile..."
61-
docker build -t ghcr.io/${{ github.repository_owner }}/biogears-builder:latest \
62-
--build-arg EXTERNAL_IMAGE=ghcr.io/${{ github.repository_owner }}/biogears-external:latest \
63-
--progress=plain \
64-
-f docker/release/Dockerfile .
65-
elif [ -f "docker/builder/Dockerfile" ]; then
66-
echo "Building with docker/builder/Dockerfile..."
67-
docker build -t ghcr.io/${{ github.repository_owner }}/biogears-builder:latest \
68-
--build-arg EXTERNAL_IMAGE=ghcr.io/${{ github.repository_owner }}/biogears-external:latest \
69-
--progress=plain \
70-
-f docker/builder/Dockerfile .
71-
else
72-
# Find a suitable Dockerfile
73-
echo "Looking for a suitable Dockerfile..."
74-
for df in $(find docker -name "Dockerfile" | grep -v external); do
75-
echo "Found Dockerfile: $df"
76-
docker build -t ghcr.io/${{ github.repository_owner }}/biogears-builder:latest \
77-
--build-arg EXTERNAL_IMAGE=ghcr.io/${{ github.repository_owner }}/biogears-external:latest \
78-
--progress=plain \
79-
-f $df .
80-
break
81-
done
96+
# Debug what Docker files exist for builder
97+
echo "Looking for builder/release Dockerfile..."
98+
BUILDER_DOCKERFILE=$(find . -name "Dockerfile" -path "*/release/*" -o -name "Dockerfile" -path "*/builder/*" | head -n 1)
99+
100+
if [ -z "$BUILDER_DOCKERFILE" ]; then
101+
echo "No builder Dockerfile found, looking for any other Dockerfile..."
102+
BUILDER_DOCKERFILE=$(find . -name "Dockerfile" | grep -v "context" | grep -v "$EXTERNAL_DOCKERFILE" | head -n 1)
103+
104+
if [ -z "$BUILDER_DOCKERFILE" ]; then
105+
echo "ERROR: No Dockerfile found for BioGears builder"
106+
exit 1
107+
fi
82108
fi
83109
110+
echo "Using Dockerfile at: $BUILDER_DOCKERFILE"
111+
DOCKERFILE_DIR=$(dirname "$BUILDER_DOCKERFILE")
112+
113+
# Build the BioGears builder image
114+
echo "Building biogears-builder image..."
115+
docker build -t ghcr.io/${{ github.repository_owner }}/biogears-hari-builder:latest \
116+
--build-arg EXTERNAL_IMAGE=ghcr.io/${{ github.repository_owner }}/biogears-hari-external:latest \
117+
--progress=plain \
118+
-f "$BUILDER_DOCKERFILE" .
119+
84120
# Tag with date-based version
85121
SHORT_SHA="${{ github.sha }}"
86122
DATE_VERSION="$(date +%Y%m%d)-${SHORT_SHA:0:8}"
87-
docker tag ghcr.io/${{ github.repository_owner }}/biogears-builder:latest ghcr.io/${{ github.repository_owner }}/biogears-builder:${DATE_VERSION}
123+
docker tag ghcr.io/${{ github.repository_owner }}/biogears-hari-builder:latest ghcr.io/${{ github.repository_owner }}/biogears-hari-builder:${DATE_VERSION}
88124
89125
# Get image digest
90-
BUILDER_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository_owner }}/biogears-builder:latest | cut -d'@' -f2 || docker images --no-trunc --quiet ghcr.io/${{ github.repository_owner }}/biogears-builder:latest)
126+
BUILDER_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository_owner }}/biogears-hari-builder:latest 2>/dev/null || docker images --no-trunc --quiet ghcr.io/${{ github.repository_owner }}/biogears-hari-builder:latest)
91127
echo "BUILDER_DIGEST=$BUILDER_DIGEST" >> image-digests.txt
92128
echo "BUILDER_VERSION=$DATE_VERSION" >> image-digests.txt
129+
echo "BUILDER_DOCKERFILE=$BUILDER_DOCKERFILE" >> image-digests.txt
93130
echo "Builder image digest: $BUILDER_DIGEST"
94131
95132
- name: Extract built artifacts from Docker image
96133
run: |
97134
# Create a temporary container to extract artifacts from
98-
CONTAINER_ID=$(docker create ghcr.io/${{ github.repository_owner }}/biogears-builder:latest)
135+
CONTAINER_ID=$(docker create ghcr.io/${{ github.repository_owner }}/biogears-hari-builder:latest)
99136
100137
# Create directories for extracted files
101138
mkdir -p build/lib build/bin
@@ -207,13 +244,13 @@ jobs:
207244
with:
208245
context: docker-context
209246
push: true
210-
tags: ghcr.io/${{ github.repository_owner }}/biogears:${{ github.sha }}
247+
tags: ghcr.io/${{ github.repository_owner }}/biogears-hari:${{ github.sha }}
211248

212249
- name: Get image digest
213250
id: image_digest
214251
run: |
215252
# Get image digest for attestations
216-
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository_owner }}/biogears:${{ github.sha }} | cut -d'@' -f2 || echo "sha256:$(docker images --no-trunc --quiet ghcr.io/${{ github.repository_owner }}/biogears:${{ github.sha }})")
253+
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository_owner }}/biogears-hari:${{ github.sha }} | cut -d'@' -f2 || echo "sha256:$(docker images --no-trunc --quiet ghcr.io/${{ github.repository_owner }}/biogears-hari:${{ github.sha }})")
217254
218255
echo "IMAGE_DIGEST=$DIGEST" > image-digest.txt
219256
echo "image_digest=$DIGEST" >> $GITHUB_OUTPUT
@@ -258,10 +295,10 @@ jobs:
258295
source image-digest.txt
259296
260297
# Generate SBOM and scan image (all in one command)
261-
trivy image --format cyclonedx --output sbom-with-vulns.cyclonedx.json ghcr.io/${{ github.repository_owner }}/biogears:${{ github.sha }}
298+
trivy image --format cyclonedx --output sbom-with-vulns.cyclonedx.json ghcr.io/${{ github.repository_owner }}/biogears-hari:${{ github.sha }}
262299
263300
# Also generate JSON format scan results for policy evaluation
264-
trivy image --format json --output trivy-scan.json ghcr.io/${{ github.repository_owner }}/biogears:${{ github.sha }}
301+
trivy image --format json --output trivy-scan.json ghcr.io/${{ github.repository_owner }}/biogears-hari:${{ github.sha }}
265302
266303
- name: Upload SBOM and scan results
267304
uses: actions/upload-artifact@v4
@@ -617,7 +654,7 @@ jobs:
617654
# Create image metadata file for in-toto attestations
618655
cat > image-data.json << EOF
619656
{
620-
"image_name": "biogears",
657+
"image_name": "biogears-hari",
621658
"image_digest": "${IMAGE_DIGEST}"
622659
}
623660
EOF
@@ -750,7 +787,7 @@ jobs:
750787
751788
- name: Publish artifacts to registry
752789
run: |
753-
REPOSITORY="ghcr.io/${{ github.repository_owner }}/biogears-artifacts"
790+
REPOSITORY="ghcr.io/${{ github.repository_owner }}/biogears-hari-artifacts"
754791
755792
# Define media types
756793
SBOM_TYPE="application/vnd.cyclonedx+json"
@@ -773,7 +810,7 @@ jobs:
773810
774811
- name: Verify artifact publishing
775812
run: |
776-
REPOSITORY="ghcr.io/${{ github.repository_owner }}/biogears-artifacts"
813+
REPOSITORY="ghcr.io/${{ github.repository_owner }}/biogears-hari-artifacts"
777814
778815
echo "Listing published artifacts:"
779816
oras discover -o tree "${REPOSITORY}:sbom-${VERSION}" || echo "Could not list SBOM"
@@ -794,17 +831,17 @@ jobs:
794831
## Artifacts
795832
796833
### Docker Image
797-
- ghcr.io/${{ github.repository_owner }}/biogears:${{ github.sha }}
834+
- ghcr.io/${{ github.repository_owner }}/biogears-hari:${{ github.sha }}
798835
799836
### Pipeline Artifacts (ORAS)
800-
- ghcr.io/${{ github.repository_owner }}/biogears-artifacts:sbom-${VERSION}
801-
- ghcr.io/${{ github.repository_owner }}/biogears-artifacts:attestations-${VERSION}
802-
- ghcr.io/${{ github.repository_owner }}/biogears-artifacts:signatures-${VERSION}
803-
- ghcr.io/${{ github.repository_owner }}/biogears-artifacts:policies-${VERSION}
837+
- ghcr.io/${{ github.repository_owner }}/biogears-hari-artifacts:sbom-${VERSION}
838+
- ghcr.io/${{ github.repository_owner }}/biogears-hari-artifacts:attestations-${VERSION}
839+
- ghcr.io/${{ github.repository_owner }}/biogears-hari-artifacts:signatures-${VERSION}
840+
- ghcr.io/${{ github.repository_owner }}/biogears-hari-artifacts:policies-${VERSION}
804841
805842
## View in GitHub Container Registry
806-
- https://github.com/${{ github.repository_owner }}/biogears/pkgs/container/biogears
807-
- https://github.com/${{ github.repository_owner }}/biogears-artifacts/pkgs/container/biogears-artifacts
843+
- https://github.com/${{ github.repository_owner }}/biogears-hari/pkgs/container/biogears-hari
844+
- https://github.com/${{ github.repository_owner }}/biogears-hari-artifacts/pkgs/container/biogears-hari-artifacts
808845
EOF
809846
810847
- name: Upload pipeline report

0 commit comments

Comments
 (0)