Skip to content

Commit 0f3e880

Browse files
committed
Attempt to setup alpine-arm64 image
1 parent d5ff7f7 commit 0f3e880

File tree

3 files changed

+128
-20
lines changed

3 files changed

+128
-20
lines changed

.docker/Dockerfile.alpine

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2023 James R. Barlow
22
# SPDX-License-Identifier: MPL-2.0
33

4-
FROM alpine:3.19 as base
4+
FROM alpine:3.19.1 as base
55

66
ENV LANG=C.UTF-8
77
ENV TZ=UTC
@@ -18,22 +18,6 @@ RUN apk add --no-cache \
1818
python3-dev \
1919
py3-pip
2020

21-
# On arm64, we need to build cffi from source.
22-
ARG TARGETPLATFORM
23-
24-
RUN if [ "${TARGETPLATFORM}" == "linux/arm64" ]; then \
25-
apk add --no-cache \
26-
build-base \
27-
autoconf \
28-
automake \
29-
libtool \
30-
zlib-dev \
31-
libffi-dev \
32-
cairo-dev \
33-
pkgconfig \
34-
; \
35-
fi
36-
3721
COPY . /app
3822

3923
WORKDIR /app

.docker/Dockerfile.alpine-arm64

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# SPDX-FileCopyrightText: 2023 James R. Barlow
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
FROM arm64v8/alpine:3.19.1 as base
5+
6+
ENV LANG=C.UTF-8
7+
ENV TZ=UTC
8+
9+
RUN apk add --no-cache \
10+
python3 \
11+
zlib
12+
13+
FROM base as builder
14+
15+
RUN apk add --no-cache \
16+
ca-certificates \
17+
git \
18+
python3-dev \
19+
py3-pip
20+
21+
# On arm64, we need to build cffi from source.
22+
RUN apk add --no-cache \
23+
build-base \
24+
autoconf \
25+
automake \
26+
libtool \
27+
zlib-dev \
28+
libffi-dev \
29+
cairo-dev \
30+
pkgconfig \
31+
; \
32+
fi
33+
34+
COPY . /app
35+
36+
WORKDIR /app
37+
38+
RUN python3 -m venv .venv
39+
40+
RUN source .venv/bin/activate \
41+
&& python3 -m pip install --no-cache-dir --upgrade pip \
42+
&& python3 -m pip install --no-cache-dir wheel \
43+
&& python3 -m pip install --no-cache-dir .[test,webservice,watcher]
44+
45+
FROM base
46+
47+
RUN apk add --no-cache \
48+
ghostscript \
49+
jbig2dec \
50+
jbig2enc \
51+
pngquant \
52+
tesseract-ocr \
53+
tesseract-ocr-data-chi_sim \
54+
tesseract-ocr-data-deu \
55+
tesseract-ocr-data-eng \
56+
tesseract-ocr-data-fra \
57+
tesseract-ocr-data-osd \
58+
tesseract-ocr-data-por \
59+
tesseract-ocr-data-spa \
60+
ttf-droid \
61+
unpaper \
62+
&& rm -rf /var/cache/apk/*
63+
64+
WORKDIR /app
65+
66+
COPY --from=builder /usr/local/lib/ /usr/local/lib/
67+
COPY --from=builder /usr/local/bin/ /usr/local/bin/
68+
69+
COPY --from=builder /app/.venv/ /app/.venv/
70+
71+
COPY --from=builder /app/misc/webservice.py /app/
72+
COPY --from=builder /app/misc/watcher.py /app/
73+
74+
# Copy minimal project files to get the test suite.
75+
COPY --from=builder /app/pyproject.toml /app/README.md /app/
76+
COPY --from=builder /app/tests /app/tests
77+
78+
ENV PATH="/app/.venv/bin:${PATH}"
79+
80+
ENTRYPOINT ["/app/.venv/bin/ocrmypdf"]

.github/workflows/build.yml

+47-3
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,52 @@ jobs:
329329
--tag "${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}-ubuntu:${DOCKER_IMAGE_TAG}" \
330330
--file .docker/Dockerfile .
331331
332-
docker_alpine:
333-
name: Build Alpine-based Docker images
332+
docker_alpine_x64:
333+
name: Build Alpine-based Docker images x64
334+
needs: [wheel_sdist_linux, test_linux, test_macos, test_windows]
335+
runs-on: ubuntu-latest
336+
if: github.event_name != 'pull_request'
337+
steps:
338+
- name: Set image tag to release or branch
339+
run: echo "DOCKER_IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
340+
341+
- name: If main, set to latest
342+
run: echo 'DOCKER_IMAGE_TAG=latest' >> $GITHUB_ENV
343+
if: env.DOCKER_IMAGE_TAG == 'main'
344+
345+
- name: Set Docker Hub repository to username
346+
run: echo "DOCKER_REPOSITORY=jbarlow83" >> $GITHUB_ENV
347+
348+
- name: Set image name
349+
run: echo "DOCKER_IMAGE_NAME=ocrmypdf-alpine" >> $GITHUB_ENV
350+
351+
- uses: actions/checkout@v4
352+
with:
353+
fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
354+
355+
- name: Login to Docker Hub
356+
uses: docker/login-action@v3
357+
with:
358+
username: jbarlow83
359+
password: ${{ secrets.DOCKERHUB_TOKEN }}
360+
361+
- name: Set up Docker Buildx
362+
id: buildx
363+
uses: docker/setup-buildx-action@v3
364+
365+
- name: Print image tag
366+
run: echo "Building image ${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
367+
368+
- name: Build
369+
run: |
370+
docker buildx build \
371+
--push \
372+
--platform linux/amd64 \
373+
--tag "${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \
374+
--file .docker/Dockerfile.alpine .
375+
376+
docker_alpine_arm64:
377+
name: Build Alpine-based Docker images arm64
334378
needs: [wheel_sdist_linux, test_linux, test_macos, test_windows]
335379
runs-on: ubuntu-latest
336380
if: github.event_name != 'pull_request'
@@ -372,6 +416,6 @@ jobs:
372416
run: |
373417
docker buildx build \
374418
--push \
375-
--platform linux/amd64 \
419+
--platform linux/arm64 \
376420
--tag "${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \
377421
--file .docker/Dockerfile.alpine .

0 commit comments

Comments
 (0)