Skip to content

Commit 8fba9eb

Browse files
authored
Fix #64: Use openSUSE image for GH Action (part 1) (#65)
* Fix #64: Use openSUSE image for GH Action We need daps and its dependencies to make the tests succeed. Modify GitHub Action workflow file to use container. * Create a two-staged Dockerfile & GH Action * Dockerfile is loosly related to https://build.opensuse.org/projects/Documentation:Containers/packages/daps-toolchain/files/Dockerfile?expand=1 * First GH Action workflow to build & publish to ghcr.io
1 parent 01cbfe5 commit 8fba9eb

4 files changed

Lines changed: 159 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
push:
77
branches:
88
- main
9+
paths:
10+
- 'src/**'
11+
- 'tests/**'
912

1013
concurrency:
1114
group: ${{ github.workflow }}-${{ github.ref }}
@@ -18,13 +21,33 @@ jobs:
1821
test:
1922
name: python
2023
runs-on: ubuntu-latest
24+
container:
25+
image: registry.opensuse.org/documentation/containers/15.6/opensuse-daps-toolchain:latest
2126

2227
steps:
2328
- name: Checkout repository
2429
uses: actions/checkout@v4
2530

26-
- name: Install tools
27-
run: sudo apt-get update && sudo apt-get install -y jing libxml2-utils xsltproc
31+
- name: Get dependencies
32+
run: |
33+
rpm -q daps \
34+
suse-xsl-stylesheets \
35+
suse-xsl-stylesheets-sbp \
36+
geekodoc \
37+
docbook-xsl-stylesheets \
38+
docbook-xsl-ns \
39+
xmlgraphics-fop \
40+
git \
41+
ditaa \
42+
libreoffice-draw \
43+
novdoc \
44+
ruby2.5-rubygem-asciidoctor \
45+
curl \
46+
tar \
47+
w3m \
48+
jq \
49+
rsvg-convert \
50+
openssh-clients || true
2851
2952
- name: Install the latest version of uv
3053
id: setup-uv
@@ -42,4 +65,4 @@ jobs:
4265

4366
- name: Run tests
4467
run: |
45-
uv run --frozen pytest -vv
68+
uv run --frozen pytest -vv
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'ci/Dockerfile'
10+
11+
jobs:
12+
build-and-publish:
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Log in to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Build Docker image
31+
run: |
32+
docker build -f ci/Dockerfile -t ghcr.io/${{ github.repository }}/daps:${{ github.sha }} .
33+
34+
- name: Push Docker image
35+
run: |
36+
docker push ghcr.io/${{ github.repository }}/daps:${{ github.sha }}
37+
38+
# (Optional) Tag as latest if on main
39+
- name: Tag latest image
40+
if: github.ref == 'refs/heads/main'
41+
run: |
42+
docker tag ghcr.io/${{ github.repository }}/daps:${{ github.sha }} ghcr.io/${{ github.repository }}/daps:latest
43+
docker push ghcr.io/${{ github.repository }}/daps:latest

changelog.d/65.infra.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use openSUSE image for GH Action

ci/Dockerfile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# syntax=docker/dockerfile:1.7
2+
3+
###############################################################################
4+
# 1. Build stage: Install daps and suse-xsl-stylesheets
5+
###############################################################################
6+
ARG OPENSUSE_VERSION=15.6
7+
ARG URL=https://download.opensuse.org/repositories
8+
9+
FROM opensuse/leap:${OPENSUSE_VERSION} AS build
10+
11+
# Add the Documentation:Tools OBS repository and refresh
12+
RUN zypper ar -f ${URL}/Documentation:/Tools/'$releasever' Documentation_Tools ; \
13+
zypper --gpg-auto-import-keys --non-interactive refresh
14+
15+
# Now install all required packages (from default + custom repo)
16+
RUN zypper --non-interactive install --no-recommends \
17+
curl ca-certificates sgml-skel gzip gpg2 \
18+
google-noto-sans-jp-regular-fonts google-noto-sans-jp-bold-fonts \
19+
google-noto-sans-sc-regular-fonts google-noto-sans-sc-bold-fonts \
20+
google-noto-sans-kr-regular-fonts google-noto-sans-kr-bold-fonts \
21+
google-noto-sans-tc-regular-fonts google-noto-sans-tc-bold-fonts \
22+
arabic-amiri-fonts sil-charis-fonts gnu-free-fonts \
23+
google-opensans-fonts dejavu-fonts google-poppins-fonts suse-fonts \
24+
daps suse-xsl-stylesheets rsvg-convert geekodoc tar w3m jq openssh-clients && \
25+
zypper clean --all
26+
27+
# Remove unneeded files and packages to minimize image size
28+
RUN rm -rf \
29+
/usr/bin/inkview \
30+
/usr/share/icons \
31+
/usr/share/man \
32+
/usr/share/help \
33+
/usr/share/locale \
34+
/usr/share/doc \
35+
/usr/share/libreoffice/help \
36+
/usr/share/inkscape/tutorials \
37+
/usr/share/inkscape/examples \
38+
/usr/share/dia/help \
39+
/usr/share/ghostscript/*/doc \
40+
/usr/lib64/libreoffice/help \
41+
/usr/lib64/libreoffice/program/wizards \
42+
/usr/lib64/libreoffice/share/gallery \
43+
/usr/lib64/libreoffice/share/template \
44+
/usr/lib64/ruby/*/rdoc \
45+
/usr/share/ghostscript/*/examples \
46+
/usr/share/inkscape/icons \
47+
/usr/share/kbd/keymaps/legacy \
48+
/usr/share/xml/docbook/schema/xsd \
49+
/usr/share/xml/docbook/stylesheet/nwalsh*/*/slides \
50+
/var/log/* \
51+
/usr/local/man \
52+
/usr/lib64/libreoffice/share/config \
53+
|| true
54+
55+
RUN rpm --erase --nodeps adwaita-icon-theme \
56+
desktop-file-utils gtk2-tools gtk3-tools \
57+
hicolor-icon-theme libreoffice-branding-openSUSE \
58+
libreoffice-icon-themes || true
59+
60+
###############################################################################
61+
# 2. Runtime stage: Minimal image with only daps and its dependencies
62+
###############################################################################
63+
FROM opensuse/leap:${OPENSUSE_VERSION}
64+
65+
LABEL maintainer="Tom Schraitle"
66+
LABEL org.opencontainers.image.source="https://github.com/openSUSE/docbuild"
67+
68+
# Copy daps and suse-xsl-stylesheets from build stage
69+
COPY --from=build /usr /usr
70+
COPY --from=build /etc /etc
71+
72+
# Final cleanup to reduce image size
73+
RUN rm -rf /var/cache/zypp/* /var/log/* /tmp/* /usr/share/man /usr/share/doc /usr/share/locale
74+
75+
# Set non-root user (optional, recommended for security)
76+
RUN useradd --create-home --shell /bin/bash dapsuser
77+
USER dapsuser
78+
79+
RUN mkdir --parents ~/.config/daps && \
80+
echo 'DOCBOOK5_RNG_URI="urn:x-suse:rng:v2:geekodoc-flat"' > ~/.config/daps/dapsrc
81+
82+
WORKDIR /workspace
83+
84+
ENV LANG=en_US.UTF-8
85+
ENV LC_ALL=en_US.UTF-8
86+
ENV TERM xterm-256color
87+
88+
# ENTRYPOINT ["daps"]
89+
# CMD ["--help"]

0 commit comments

Comments
 (0)