@@ -12,90 +12,131 @@ permissions:
1212 packages : write
1313
1414jobs :
15- # Build BioGears from source on Linux
15+ # Build BioGears from source on Linux using Docker
1616 build-linux :
1717 name : Build BioGears (Linux)
1818 runs-on : ubuntu-latest
19- strategy :
20- matrix :
21- build_type : [Release] # We'll focus on Release for the pipeline
2219
2320 steps :
2421 - name : Checkout code
2522 uses : actions/checkout@v3
2623 with :
2724 fetch-depth : 0
2825
29- - name : Install dependencies
26+ - name : Set up Docker Buildx
27+ uses : docker/setup-buildx-action@v2
28+
29+ - name : Login to GitHub Container Registry
30+ uses : docker/login-action@v3
31+ with :
32+ registry : ghcr.io
33+ username : ${{ github.actor }}
34+ password : ${{ secrets.GITHUB_TOKEN }}
35+
36+ - name : Build External Base Image
3037 run : |
31- sudo apt-get update
32- sudo apt-get install -y cmake build-essential liblog4cpp5-dev libxerces-c-dev libeigen3-dev wget \
33- git gcc g++ make cmake pkg-config libtool autoconf valgrind \
34- ninja-build ccache libboost-all-dev doxygen graphviz
35-
36- # Check installed dependency versions
37- echo "===== DEPENDENCY VERSIONS ====="
38- g++ --version
39- cmake --version
40- pkg-config --version
41- echo "===== LIBRARY VERSIONS ====="
42- pkg-config --modversion eigen3 || echo "eigen3.pc not found"
43- pkg-config --modversion xerces-c || echo "xerces-c.pc not found"
44- pkg-config --modversion log4cpp || echo "log4cpp.pc not found"
45-
46- # Install CodeSynthesis XSD
47- echo "===== INSTALLING CODESYNTHESIS XSD ====="
48- wget https://www.codesynthesis.com/download/xsd/4.0/linux-gnu/x86_64/xsd_4.0.0-1_amd64.deb
49- sudo dpkg -i xsd_4.0.0-1_amd64.deb
50- xsd --version || echo "xsd not properly installed"
51-
52- # Check directory structure
53- echo "===== DIRECTORY STRUCTURE ====="
54- ls -la
55-
56- - name : Configure CMake
38+ # Build the external dependencies image first
39+ echo "Building biogears-external image..."
40+
41+ docker build -t ghcr.io/${{ github.repository_owner }}/biogears-external:latest --progress=plain -f docker/external/Dockerfile docker/external
42+
43+ # Tag with date-based version
44+ SHORT_SHA="${{ github.sha }}"
45+ 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}
47+
48+ # 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)
50+ echo "EXTERNAL_DIGEST=$EXTERNAL_DIGEST" > image-digests.txt
51+ echo "EXTERNAL_VERSION=$DATE_VERSION" >> image-digests.txt
52+ echo "External image digest: $EXTERNAL_DIGEST"
53+
54+ - name : Build BioGears with Docker
5755 run : |
58- mkdir -p build
59- cd build
60- cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_VERBOSE_MAKEFILE=ON
56+ # Build the BioGears builder image
57+ echo "Building biogears-builder image..."
58+
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
82+ fi
83+
84+ # Tag with date-based version
85+ SHORT_SHA="${{ github.sha }}"
86+ 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}
88+
89+ # 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)
91+ echo "BUILDER_DIGEST=$BUILDER_DIGEST" >> image-digests.txt
92+ echo "BUILDER_VERSION=$DATE_VERSION" >> image-digests.txt
93+ echo "Builder image digest: $BUILDER_DIGEST"
6194
62- - name : Build BioGears
95+ - name : Extract built artifacts from Docker image
6396 run : |
64- cd build
65- echo "Processor count: $(nproc)"
66- echo "CMake version: $(cmake --version)"
67- echo "GCC version: $(gcc --version)"
68- echo "Build directory contents:"
69- ls -la
70- # Build with more verbose output and show where it fails
71- cmake --build . --parallel $(nproc) --verbose || {
72- echo "===== BUILD FAILED ====="
73- echo "Last 100 lines of CMakeFiles/CMakeError.log:"
74- tail -n 100 CMakeFiles/CMakeError.log || echo "No CMakeError.log found"
75- echo "===== DETAILED ENVIRONMENT INFO ====="
76- env | sort
77- exit 1
78- }
97+ # Create a temporary container to extract artifacts from
98+ CONTAINER_ID=$(docker create ghcr.io/${{ github.repository_owner }}/biogears-builder:latest)
99+
100+ # Create directories for extracted files
101+ mkdir -p build/lib build/bin
102+
103+ # Extract the built libraries and binaries
104+ docker cp $CONTAINER_ID:/usr/local/lib/. build/lib/
105+ docker cp $CONTAINER_ID:/usr/local/bin/. build/bin/
106+
107+ # Remove the temporary container
108+ docker rm $CONTAINER_ID
109+
110+ # List extracted contents
111+ echo "Extracted libraries:"
112+ ls -la build/lib/
113+ echo "Extracted binaries:"
114+ ls -la build/bin/
79115
80116 - name : Create build metadata
81117 run : |
118+ source image-digests.txt
82119 cat > build-metadata.json << EOF
83120 {
84- "builder_id": "github-actions",
85- "build_type": "${{ matrix.build_type }} ",
121+ "builder_id": "github-actions-docker ",
122+ "build_type": "Release ",
86123 "source_repo": "${{ github.server_url }}/${{ github.repository }}",
87124 "commit_hash": "${{ github.sha }}",
88125 "build_timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
89- "build_platform": "linux"
126+ "build_platform": "linux",
127+ "docker_images": {
128+ "external": {
129+ "tag": "${EXTERNAL_VERSION}",
130+ "digest": "${EXTERNAL_DIGEST}"
131+ },
132+ "builder": {
133+ "tag": "${BUILDER_VERSION}",
134+ "digest": "${BUILDER_DIGEST}"
135+ }
136+ }
90137 }
91138 EOF
92139
93- - name : Run tests
94- run : |
95- cd build
96- # Run only a small subset of tests for CI pipeline demonstration
97- ctest -C ${{ matrix.build_type }} --output-on-failure -R "^(CommonData|CDM)" || true
98-
99140 - name : Upload build artifacts
100141 uses : actions/upload-artifact@v4
101142 with :
@@ -104,8 +145,8 @@ jobs:
104145 build/lib/
105146 build/bin/
106147 build-metadata.json
107-
108- # Build Docker images containing BioGears
148+
149+ # Build Docker runtime image containing BioGears
109150 build-docker :
110151 name : Build Docker Images
111152 needs : build-linux
0 commit comments