From 600da6e9e33e21915821e0a0c7a63def004846ab Mon Sep 17 00:00:00 2001 From: a76yyyy <56478790+a76yyyy@users.noreply.github.com> Date: Fri, 31 Jan 2025 07:48:16 +0800 Subject: [PATCH] Initial commit --- .github/workflows/Build Image.yml | 62 +++++++++++++++++++++ .github/workflows/DockerHub-Description.yml | 22 ++++++++ .gitignore | 5 ++ Dockerfile | 51 +++++++++++++++++ README.md | 20 +++++++ 5 files changed, 160 insertions(+) create mode 100644 .github/workflows/Build Image.yml create mode 100644 .github/workflows/DockerHub-Description.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.github/workflows/Build Image.yml b/.github/workflows/Build Image.yml new file mode 100644 index 0000000..2e952f1 --- /dev/null +++ b/.github/workflows/Build Image.yml @@ -0,0 +1,62 @@ +name: Publish Package +on: + workflow_dispatch: {} + push: + paths-ignore: + - '.github/**' + - '**.md' + tags: ["*"] + +jobs: + build: + runs-on: ubuntu-latest + name: Publish Package job + + + 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 + - + id: login-ghcr + name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} # dockerServer Username 在setting创建secrets name=DOCKER_USERNAME value=dockerid + password: ${{ secrets.GITHUB_TOKEN }} # dockerServer Token + continue-on-error: true + - + id: login-dockerhub + name: Login to DockerHub + uses: docker/login-action@v3 + with: + registry: docker.io + username: ${{ secrets.DOCKER_USERNAME }} # dockerServer Username 在setting创建secrets name=DOCKER_USERNAME value=dockerid + password: ${{ secrets.DOCKER_PASSWORD }} # dockerServer Token 在setting创建secrets name=DOCKER_PASSWORD value=dockerToken + continue-on-error: true + - + id: meta + name: Docker meta + uses: docker/metadata-action@v5 + with: + images: | + name=ghcr.io/${{ github.repository_owner }}/ddddocr,enable=${{ steps.login-ghcr.outcome == 'success' }} + name=docker.io/a76yyyy/ddddocr,enable=${{ steps.login-dockerhub.outcome == 'success' }} + tags: | + type=ref,event=tag + - + name: Publish Latest Package + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/386,linux/arm64,linux/amd64,linux/arm/v6,linux/arm/v7,linux/ppc64le,linux/s390x # 你准备构建的镜像平台 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/DockerHub-Description.yml b/.github/workflows/DockerHub-Description.yml new file mode 100644 index 0000000..6278076 --- /dev/null +++ b/.github/workflows/DockerHub-Description.yml @@ -0,0 +1,22 @@ +name: Update Docker Hub Description +on: + push: + branches: + - main + paths: + - README.md + - .github/workflows/DockerHub-Description.yml +jobs: + dockerHubDescription: + if: startsWith(github.repository, 'qd-today/ddddocr-docker') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Docker Hub Description + uses: peter-evans/dockerhub-description@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + repository: a76yyyy/ddddocr + short-description: ${{ github.event.repository.description }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..078b9cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.vscode +.history +.python-version +venv +.lh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..72462f4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +# 基础镜像 +FROM alpine:edge + +# 维护者信息 +LABEL maintainer "a76yyyy " +LABEL org.opencontainers.image.source=https://github.com/qd-today/ddddocr-docker +ARG TARGETPLATFORM + +ARG APK_MIRROR="" #e.g., https://mirrors.tuna.tsinghua.edu.cn +ARG PIP_MIRROR="" #e.g., https://pypi.tuna.tsinghua.edu.cn/simple +ARG GIT_DOMAIN=https://github.com #e.g., https://gh-proxy.com/https://github.com or https://gitee.com + +# Envirenment for dddocr +ARG DDDDOCR_VERSION=master +# ENV DDDDOCR_VERSION=${DDDDOCR_VERSION} + +# Install packages +RUN <> /etc/apk/repositories +APK_CMD="apk" +if [ "x" != "x${APK_MIRROR}" ]; then + APK_CMD="apk --repositories-file=/dev/null -X $APK_MIRROR/alpine/edge/main -X $APK_MIRROR/alpine/edge/community -X $APK_MIRROR/alpine/edge/testing" +fi +$APK_CMD update +$APK_CMD add --update --no-cache bash git tzdata ca-certificates file python3 py3-six +# ln -s /usr/bin/python3 /usr/bin/python +if [ "${TARGETPLATFORM}" = "linux/amd64" ] || [ "${TARGETPLATFORM}" = "linux/arm64" ] || [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then + $APK_CMD add --update --no-cache py3-pillow py3-onnxruntime py3-opencv libprotobuf-lite + $APK_CMD add --update --no-cache --virtual .build_deps py3-pip py3-setuptools py3-wheel \ + protobuf-dev py3-numpy-dev lld samurai build-base gcc python3-dev musl-dev linux-headers make + git clone --branch $DDDDOCR_VERSION --depth 1 $GIT_DOMAIN/sml2h3/ddddocr.git + cd /ddddocr + sed -i '/install_package_data/d' setup.py + sed -i '/install_requires/d' setup.py + sed -i '/python_requires/d' setup.py + PIP_INSTALL="pip install" + if [ "x" != "x$PIP_MIRROR" ]; then + PIP_INSTALL="pip install --index-url $PIP_MIRROR" + fi + $PIP_INSTALL --no-cache-dir --compile --break-system-packages . + cd / && rm -rf /ddddocr + $APK_CMD del .build_deps; +else + $APK_CMD add --update --no-cache libprotobuf-lite + echo "py3-pillow/py3-onnxruntime/py3-opencv does not currently support ${TARGETPLATFORM}." +fi +rm -rf /var/cache/apk/* +rm -rf /usr/share/man/* +EOT diff --git a/README.md b/README.md new file mode 100644 index 0000000..f23c5e0 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# **ddddocr-Docker** + +## **Repository** + +**Github :** [https://github.com/qd-today/ddddocr-docker](https://github.com/qd-today/ddddocr-docker) + +**DockerHub :** [https://hub.docker.com/r/a76yyyy/ddddocr](https://hub.docker.com/r/a76yyyy/ddddocr) + +```bash +docker pull a76yyyy/ddddocr:latest +``` + +## **VERSION** + +- PYTHON_VERSION == 3.11 +- DDDDOCR_VERSION == LATEST(v1.4.7) + +## **Tips** + +> Onnxruntime Builder does not currently support building i386 and s390x wheels!