Skip to content

Commit 3c87f74

Browse files
committed
Add docker image
Thanks @verglor Fixes #18
1 parent 629baf2 commit 3c87f74

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

.github/workflows/publish.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,49 @@ jobs:
8686
run: >-
8787
gh release upload
8888
'${{ github.ref_name }}' dist/**
89-
--repo '${{ github.repository }}'
89+
--repo '${{ github.repository }}'
90+
91+
docker:
92+
name: Build Ubuntu-based Docker image
93+
needs: github-release
94+
runs-on: ubuntu-latest
95+
if: github.event_name != 'pull_request'
96+
steps:
97+
- name: Set image tag to release or branch
98+
run: echo "DOCKER_IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
99+
100+
- name: If main, set to latest
101+
run: echo 'DOCKER_IMAGE_TAG=latest' >> $GITHUB_ENV
102+
if: env.DOCKER_IMAGE_TAG == 'main'
103+
104+
- name: Set Docker Hub repository to username
105+
run: echo "DOCKER_REPOSITORY=jbarlow83" >> $GITHUB_ENV
106+
107+
- name: Set image name
108+
run: echo "DOCKER_IMAGE_NAME=ocrmypdf-easyocr" >> $GITHUB_ENV
109+
110+
- uses: actions/checkout@v5
111+
with:
112+
fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
113+
114+
- name: Login to Docker Hub
115+
uses: docker/login-action@v3
116+
with:
117+
username: jbarlow83
118+
password: ${{ secrets.DOCKERHUB_TOKEN }}
119+
120+
- name: Set up Docker Buildx
121+
id: buildx
122+
uses: docker/setup-buildx-action@v3
123+
124+
- name: Print image tag
125+
run: echo "Building image ${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
126+
127+
- name: Build
128+
run: |
129+
docker buildx build \
130+
--push \
131+
--platform linux/amd64 \
132+
--tag "${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \
133+
--tag "${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}-ubuntu:${DOCKER_IMAGE_TAG}" \
134+
--file .docker/Dockerfile .

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM jbarlow83/ocrmypdf
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
curl git ca-certificates \
5+
&& rm -rf /var/lib/apt/lists/*
6+
7+
# Seed pip into the ocrmypdf venv
8+
RUN set -eux; \
9+
curl -fsSL https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py; \
10+
/app/.venv/bin/python /tmp/get-pip.py; \
11+
/app/.venv/bin/pip --version; \
12+
rm -f /tmp/get-pip.py
13+
14+
RUN /app/.venv/bin/pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu124
15+
16+
RUN /app/.venv/bin/pip install --no-cache-dir git+https://github.com/ocrmypdf/OCRmyPDF-EasyOCR.git

0 commit comments

Comments
 (0)