100 lines
3.1 KiB
YAML
100 lines
3.1 KiB
YAML
name: build_docker
|
|
run-name: ${{ gitea.event.head_commit.message }}
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
essential:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
Version: 1.0.${{ gitea.run_number }}
|
|
repo: seryus.ddns.net
|
|
image_cpu: seryus.ddns.net/unir/paddle-ocr-cpu
|
|
image_gpu: seryus.ddns.net/unir/paddle-ocr-gpu
|
|
steps:
|
|
- name: Output version info
|
|
run: |
|
|
echo "## Build Info" >> $GITHUB_STEP_SUMMARY
|
|
echo "Version: 1.0.${{ gitea.run_number }}" >> $GITHUB_STEP_SUMMARY
|
|
echo "Event: ${{ gitea.event_name }}" >> $GITHUB_STEP_SUMMARY
|
|
|
|
# CPU image: Matrix build for amd64 and arm64 (each pushes as soon as done)
|
|
build_cpu:
|
|
runs-on: ubuntu-latest
|
|
needs: essential
|
|
strategy:
|
|
matrix:
|
|
platform:
|
|
- linux/amd64
|
|
- linux/arm64
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ needs.essential.outputs.repo }}
|
|
username: username
|
|
password: ${{ secrets.UNIR_REGISTRY_TOKEN }}
|
|
|
|
- name: Get arch suffix
|
|
id: arch
|
|
run: |
|
|
if [ "${{ matrix.platform }}" = "linux/amd64" ]; then
|
|
echo "suffix=amd64" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "suffix=arm64" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Build and push CPU image (${{ matrix.platform }})
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: src/paddle_ocr
|
|
file: src/paddle_ocr/Dockerfile.cpu
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
tags: |
|
|
${{ needs.essential.outputs.image_cpu }}:${{ needs.essential.outputs.Version }}-${{ steps.arch.outputs.suffix }}
|
|
${{ needs.essential.outputs.image_cpu }}:${{ steps.arch.outputs.suffix }}
|
|
|
|
# GPU image: x86_64 only (PaddlePaddle GPU doesn't support ARM64)
|
|
build_gpu:
|
|
runs-on: ubuntu-latest
|
|
needs: essential
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea Registry
|
|
run: |
|
|
echo ${{ secrets.UNIR_REGISTRY_TOKEN }} | docker login \
|
|
-u username \
|
|
--password-stdin ${{ needs.essential.outputs.repo }}
|
|
|
|
- name: Build GPU image (x86_64)
|
|
run: |
|
|
docker build \
|
|
-f src/paddle_ocr/Dockerfile.gpu \
|
|
-t ${{ needs.essential.outputs.image_gpu }}:${{ needs.essential.outputs.Version }} \
|
|
-t ${{ needs.essential.outputs.image_gpu }}:latest \
|
|
src/paddle_ocr/
|
|
|
|
- name: Push GPU image
|
|
run: |
|
|
docker push ${{ needs.essential.outputs.image_gpu }}:${{ needs.essential.outputs.Version }}
|
|
docker push ${{ needs.essential.outputs.image_gpu }}:latest
|