name: Test Multi-Architecture Docker Build on: workflow_call: workflow_dispatch: permissions: contents: read jobs: test-multiarch-build: name: Test Multi-Arch Docker Build strategy: matrix: include: - platform: linux/amd64 runs-on: ubuntu-latest platform_slug: linux-amd64 - platform: linux/arm64 runs-on: ubuntu-24.04-arm platform_slug: linux-arm64 runs-on: ${{ matrix.runs-on }} timeout-minutes: 60 steps: - name: Harden the runner (Audit all outbound calls) uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 with: egress-policy: audit - name: Check out the repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false fetch-depth: 0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - name: Build Docker image for ${{ matrix.platform }} uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0 with: context: . platforms: ${{ matrix.platform }} push: false load: false cache-from: type=gha,scope=${{ matrix.platform_slug }} cache-to: type=gha,mode=max,scope=${{ matrix.platform_slug }} tags: ldr-test:${{ matrix.platform_slug }}-${{ github.sha }} outputs: type=docker,dest=/tmp/image-${{ matrix.platform_slug }}.tar - name: Inspect built image run: | # Load and inspect the image docker load < "/tmp/image-${{ matrix.platform_slug }}.tar" docker image inspect ldr-test:${{ matrix.platform_slug }}-${{ github.sha }} # Get image size IMAGE_SIZE=$(docker image inspect ldr-test:${{ matrix.platform_slug }}-${{ github.sha }} --format='{{.Size}}' | numfmt --to=iec) echo "Image size for ${{ matrix.platform }}: $IMAGE_SIZE" - name: Test image startup run: | docker load < "/tmp/image-${{ matrix.platform_slug }}.tar" # Test that the container can start and Python works docker run --rm --platform ${{ matrix.platform }} \ ldr-test:${{ matrix.platform_slug }}-${{ github.sha }} \ python -c "import sys; print(f'Python {sys.version} on {sys.platform}')" # Test that the LDR package is installed docker run --rm --platform ${{ matrix.platform }} \ ldr-test:${{ matrix.platform_slug }}-${{ github.sha }} \ python -c "import local_deep_research; print('LDR package imported successfully')" - name: Test web server startup run: | docker load < "/tmp/image-${{ matrix.platform_slug }}.tar" # Start the container in background docker run -d --name ldr-test \ --platform ${{ matrix.platform }} \ -p 5000:5000 \ -e LDR_DB_CONFIG_KDF_ITERATIONS=1000 \ -e LDR_TEST_MODE=1 \ -e LDR_NEWS_SCHEDULER_ENABLED=false \ ldr-test:${{ matrix.platform_slug }}-${{ github.sha }} # Wait for server to start TIMEOUT_SECONDS=60 echo "Waiting for server to start (timeout: ${TIMEOUT_SECONDS}s)..." for i in $(seq 1 ${TIMEOUT_SECONDS}); do if curl -fsS --connect-timeout 2 --max-time 5 http://localhost:5000/api/v1/health 2>/dev/null; then echo "✅ Server started successfully after ${i} seconds on ${{ matrix.platform }}!" break fi # Show progress every 10 seconds if [ $((i % 10)) -eq 0 ]; then echo "Still waiting... (${i}s elapsed)" fi if [ "$i" -eq "${TIMEOUT_SECONDS}" ]; then echo "❌ Server failed to start within ${TIMEOUT_SECONDS} seconds" docker logs ldr-test exit 1 fi sleep 1 done # Check server response RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000) echo "Server response code: $RESPONSE" # Clean up docker stop ldr-test docker rm ldr-test summary: name: Build Summary needs: test-multiarch-build runs-on: ubuntu-latest timeout-minutes: 5 if: always() steps: - name: Harden the runner (Audit all outbound calls) uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 with: egress-policy: audit - name: Summary env: BUILD_RESULT: ${{ needs.test-multiarch-build.result }} run: | { echo "## Multi-Architecture Build Test Results" echo "" } >> "$GITHUB_STEP_SUMMARY" if [ "$BUILD_RESULT" == "success" ]; then { echo "✅ **All platforms built and tested successfully!**" echo "" echo "### Tested Platforms:" echo "- linux/amd64 ✅" echo "- linux/arm64 ✅" echo "" echo "The Docker image is ready for multi-architecture deployment." } >> "$GITHUB_STEP_SUMMARY" else { echo "❌ **Build or tests failed**" echo "" echo "Please check the logs above for details." } >> "$GITHUB_STEP_SUMMARY" fi