| name: Fineract Docker Builds |
| |
| on: |
| workflow_call: |
| secrets: |
| DEVELOCITY_ACCESS_KEY: |
| required: false |
| |
| permissions: |
| contents: read |
| |
| jobs: |
| build: |
| runs-on: ubuntu-24.04 |
| timeout-minutes: 90 |
| strategy: |
| fail-fast: false |
| matrix: |
| db_type: [mariadb, postgresql] |
| include: |
| - db_type: mariadb |
| compose_file: docker-compose.yml |
| - db_type: postgresql |
| compose_file: docker-compose-postgresql.yml |
| |
| env: |
| DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} |
| IMAGE_NAME: fineract |
| DOCKER_LOG_DIR: ci-logs/docker-${{ matrix.db_type }} |
| |
| steps: |
| - name: Set up JDK 21 |
| uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5 |
| with: |
| java-version: '21' |
| distribution: 'zulu' |
| |
| - name: Download workspace |
| id: download-workspace |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 |
| continue-on-error: true |
| with: |
| name: fineract-workspace-${{ github.run_id }} |
| path: . |
| |
| - name: Extract workspace |
| if: steps.download-workspace.outcome == 'success' |
| run: tar -xf fineract-workspace.tar |
| |
| - name: Checkout |
| if: steps.download-workspace.outcome != 'success' |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| with: |
| persist-credentials: false |
| fetch-depth: 0 |
| fetch-tags: true |
| |
| - name: Build workspace fallback |
| if: steps.download-workspace.outcome != 'success' |
| uses: ./.github/actions/setup-and-build-fineract |
| with: |
| cache-read-only: false |
| |
| - name: Setup Gradle |
| uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 |
| |
| - name: Build the image |
| run: ./gradlew --no-daemon --console=plain :fineract-provider:jibDockerBuild -Djib.to.image=$IMAGE_NAME -x test -x cucumber -x buildJavaSdk |
| |
| - name: Verify git.properties in image |
| run: | |
| docker create --name fineract-inspect $IMAGE_NAME |
| docker export fineract-inspect | tar -tf - | grep 'git.properties' |
| docker rm fineract-inspect |
| |
| - name: Start the ${{ matrix.db_type }} stack |
| run: docker compose -f ${{ matrix.compose_file }} up -d |
| |
| - name: Check the stack |
| run: docker ps |
| |
| - name: Check health Manager |
| run: curl -f -k --retry 60 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health |
| |
| - name: Check info Manager |
| run: | |
| curl -f -k --retry 5 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info -o actuator-info.json |
| cat actuator-info.json |
| jq -e '.git | type == "object"' actuator-info.json |
| |
| - name: Collect Docker logs |
| if: failure() |
| run: | |
| mkdir -p "$DOCKER_LOG_DIR" |
| docker ps -a > "$DOCKER_LOG_DIR/docker-ps.txt" 2>&1 || true |
| docker compose -f ${{ matrix.compose_file }} ps --all > "$DOCKER_LOG_DIR/docker-compose-ps.txt" 2>&1 || true |
| docker compose -f ${{ matrix.compose_file }} logs --no-color --timestamps > "$DOCKER_LOG_DIR/docker-compose.log" 2>&1 || true |
| docker stats --no-stream > "$DOCKER_LOG_DIR/docker-stats.txt" 2>&1 || true |
| |
| docker compose -f ${{ matrix.compose_file }} ps -q | while read -r container_id; do |
| [ -n "$container_id" ] || continue |
| container_name="$(docker inspect --format '{{.Name}}' "$container_id" 2>/dev/null | sed 's#^/##; s#[^A-Za-z0-9_.-]#_#g')" |
| [ -n "$container_name" ] || container_name="$container_id" |
| docker logs --timestamps "$container_id" > "$DOCKER_LOG_DIR/${container_name}.log" 2>&1 || true |
| docker inspect "$container_id" > "$DOCKER_LOG_DIR/${container_name}.inspect.json" 2>&1 || true |
| done |
| |
| - name: Upload Docker logs |
| if: failure() |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| with: |
| name: docker-logs-${{ matrix.db_type }}-attempt-${{ github.run_attempt }} |
| path: ci-logs/ |
| if-no-files-found: ignore |
| retention-days: 5 |
| compression-level: 9 |
| |
| - name: Clean up |
| if: always() |
| run: docker compose -f ${{ matrix.compose_file }} down -v |