Skip to content

Commit 71bb1de

Browse files
committed
Modernize image: latexmk/chktex/latexindent/biber/IEEEtran, GHCR multi-arch publish
- Dockerfile: add latexmk, chktex, biber, texlive-extra-utils (latexindent, dvisvgm), texlive-bibtex-extra, texlive-publishers (IEEEtran.bst), texlive-science, make/git/python3 on top of the existing Ubuntu TeX Live base - Makefile: image is ghcr.io/mathapedia/latex; latexmk-driven tex/pstricks targets; make check smoke-tests tools/packages; RUN_IMAGE override - CI: build, smoke test, compile test.tex, push amd64+arm64 to GHCR on main/tags (replaces build-pdf.yml which pulled the Docker Hub image) - README rewrite
1 parent c818930 commit 71bb1de

7 files changed

Lines changed: 211 additions & 183 deletions

File tree

‎.github/workflows/build-docker.yml‎

Lines changed: 72 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,78 @@
1-
name: Build LaTeX and Docker
1+
name: Build and publish image
22

33
on:
4-
workflow_dispatch: # Allows manual triggering of the workflow
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
paths-ignore: ["README.md", "tex/**"]
8+
pull_request:
9+
branches: [main]
10+
paths-ignore: ["README.md"]
11+
workflow_dispatch:
12+
13+
env:
14+
IMAGE: ghcr.io/${{ github.repository_owner }}/latex
515

616
jobs:
7-
build-latex:
17+
image:
818
runs-on: ubuntu-latest
9-
19+
permissions:
20+
contents: read
21+
packages: write
1022
steps:
11-
# Checkout the repository
12-
- name: Checkout repository
13-
uses: actions/checkout@v4
14-
15-
# Build the Docker image from the provided Dockerfile
16-
- name: Build Docker image
17-
run: |
18-
docker build -t latex-build:latest latex/
19-
20-
# Compile the LaTeX file using the built Docker image
21-
- name: Build LaTeX PDF
22-
run: |
23-
docker run --rm \
24-
-v ${{ github.workspace }}/tex:/usr/src \
25-
latex-build:latest \
26-
pdflatex test.tex
27-
28-
# Compile the LaTeX file using the built Docker image
29-
- name: Build LaTeX PDF
30-
run: |
31-
docker run --rm \
32-
-v ${{ github.workspace }}/tex:/usr/src \
33-
latex-build:latest \
34-
sh -c "\
35-
export PATH=/usr/bin:\$PATH && \
36-
latex test.tex && \
37-
dvips test.dvi -o test.ps && \
38-
ps2pdf test.ps test.pdf"
39-
40-
# Upload the compiled PDF as an artifact
41-
- name: Upload PDF Artifact
42-
uses: actions/upload-artifact@v4
43-
with:
44-
name: test.pdf
45-
path: tex/test.pdf
23+
- uses: actions/checkout@v4
24+
25+
- uses: docker/setup-qemu-action@v3
26+
- uses: docker/setup-buildx-action@v3
27+
28+
- name: Log in to GHCR
29+
if: github.event_name != 'pull_request'
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Image tags
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env.IMAGE }}
41+
tags: |
42+
type=raw,value=latest,enable={{is_default_branch}}
43+
type=semver,pattern={{version}}
44+
type=semver,pattern={{major}}.{{minor}}
45+
type=sha
46+
47+
# amd64 only for the smoke test (fast); the multi-arch push happens below.
48+
- name: Build (amd64, load locally)
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: latex
52+
load: true
53+
tags: ${{ env.IMAGE }}:ci
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max
56+
57+
- name: Smoke test tools and packages
58+
run: make check RUN_IMAGE=${{ env.IMAGE }}:ci
59+
60+
- name: Compile test document (latex -> dvips -> ps2pdf)
61+
run: make clean-latex pstricks RUN_IMAGE=${{ env.IMAGE }}:ci
62+
63+
- uses: actions/upload-artifact@v4
64+
with:
65+
name: test.pdf
66+
path: tex/test.pdf
67+
68+
- name: Push (amd64 + arm64)
69+
if: github.event_name != 'pull_request'
70+
uses: docker/build-push-action@v6
71+
with:
72+
context: latex
73+
platforms: linux/amd64,linux/arm64
74+
push: true
75+
tags: ${{ steps.meta.outputs.tags }}
76+
labels: ${{ steps.meta.outputs.labels }}
77+
cache-from: type=gha
78+
cache-to: type=gha,mode=max

‎.github/workflows/build-pdf.yml‎

Lines changed: 0 additions & 49 deletions
This file was deleted.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ node_modules
99
*.tmp
1010
*.bak
1111
*.dvi
12+
*.ps
1213
*.xdv
1314

1415
# LaTeX build files

‎Makefile‎

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,68 @@
11
# Image name and version tag
2-
IMAGE_NAME := pyramation/pstricks-latex
3-
TAG := 1.0.0
2+
IMAGE_NAME := ghcr.io/mathapedia/latex
3+
TAG := $(shell git describe --tags --always 2>/dev/null || echo dev)
4+
PLATFORMS := linux/amd64,linux/arm64
45

5-
# Default target: Build and run the Docker Compose environment
6-
def: cleanup
7-
docker-compose down && docker-compose build && docker-compose up
6+
# Legacy Docker Hub name (kept for existing consumers)
7+
LEGACY_IMAGE := pyramation/pstricks-latex
88

9-
# Open an interactive shell in the LaTeX Docker container
10-
ssh:
11-
docker run -v `pwd`/tex:/usr/src -i -t $(IMAGE_NAME) /bin/bash
9+
# Image ref used by the run targets (ssh/tex/pstricks/check)
10+
RUN_IMAGE ?= $(IMAGE_NAME):latest
1211

13-
# Clean Git repository and remove untracked files
14-
clean:
15-
@git reset --hard
16-
@git ls-files --other --exclude-standard | xargs rm -f
12+
# Default: build the image and compile the test document with it
13+
def: build pstricks
1714

18-
# Build the LaTeX document using Docker
19-
tex:
20-
docker run -v `pwd`/tex:/usr/src $(IMAGE_NAME) pdflatex test.tex
15+
# Build the image locally (single platform, loaded into the docker daemon)
16+
build:
17+
docker build -t $(IMAGE_NAME):$(TAG) -t $(IMAGE_NAME):latest ./latex
2118

22-
# Build the LaTeX document with PSTricks using Docker
23-
pstricks:
24-
docker run -v `pwd`/tex:/usr/src $(IMAGE_NAME) sh -c "\
25-
latex test.tex && \
26-
dvips test.dvi -o test.ps && \
27-
ps2pdf test.ps test.pdf"
19+
# Multi-arch build + push (needs `docker buildx`; CI does this on tags)
20+
buildx:
21+
docker buildx build --platform $(PLATFORMS) \
22+
-t $(IMAGE_NAME):$(TAG) -t $(IMAGE_NAME):latest --push ./latex
2823

29-
# Clean LaTeX auxiliary files
30-
clean-latex:
31-
find tex/ -type f \( -name "*.aux" -o -name "*.log" -o -name "*.out" -o -name "*.synctex.gz" -o -name "*.toc" \) -delete
24+
# Push the locally built image
25+
push:
26+
docker push $(IMAGE_NAME):$(TAG)
27+
docker push $(IMAGE_NAME):latest
28+
29+
# Also tag/push under the legacy Docker Hub name
30+
push-legacy:
31+
docker tag $(IMAGE_NAME):latest $(LEGACY_IMAGE):latest
32+
docker push $(LEGACY_IMAGE):latest
3233

33-
# Build Docker image using the Dockerfile in ./latex
34-
build: cleanup
35-
docker build -t $(IMAGE_NAME):$(TAG) ./latex
34+
# Open an interactive shell in the container with ./tex mounted
35+
ssh:
36+
docker run --rm -it -v `pwd`/tex:/usr/src $(RUN_IMAGE) /bin/bash
3637

37-
# Tag the image as "latest"
38-
tag-latest:
39-
docker tag $(IMAGE_NAME):$(TAG) $(IMAGE_NAME):latest
38+
# Compile a plain document with pdflatex (test.tex itself needs the PSTricks route)
39+
tex:
40+
docker run --rm -v `pwd`/tex:/usr/src $(RUN_IMAGE) \
41+
latexmk -pdf -interaction=nonstopmode -halt-on-error test.tex
4042

41-
# Push Docker image (both versioned and latest tags)
42-
push: build tag-latest
43-
docker push $(IMAGE_NAME):$(TAG)
44-
docker push $(IMAGE_NAME):latest
45-
echo "Image pushed with tags: $(TAG) and latest"
43+
# Compile the test document via latex -> dvips -> ps2pdf (PSTricks route)
44+
pstricks:
45+
docker run --rm -v `pwd`/tex:/usr/src $(RUN_IMAGE) \
46+
latexmk -pdfps -interaction=nonstopmode -halt-on-error test.tex
47+
48+
# Smoke test: every tool the Mathapedia boilerplate relies on must be present
49+
check:
50+
docker run --rm $(RUN_IMAGE) sh -c '\
51+
set -e; \
52+
for t in latex pdflatex dvips ps2pdf latexmk bibtex biber chktex latexindent dvisvgm gs node; do \
53+
command -v $$t >/dev/null || { echo "missing: $$t"; exit 1; }; \
54+
done; \
55+
for f in pstricks.sty pst-plot.sty tikz.sty pgfplots.sty cleveref.sty IEEEtran.bst; do \
56+
kpsewhich $$f >/dev/null || { echo "missing: $$f"; exit 1; }; \
57+
done; \
58+
echo ok'
4659

47-
# Cleanup any existing container with the name "pstricks-latex"
48-
cleanup:
49-
@if [ ! -z "$$(docker ps -aq -f name=pstricks-latex)" ]; then \
50-
echo "Stopping and removing existing container..."; \
51-
docker stop pstricks-latex && docker rm pstricks-latex; \
52-
fi
60+
# Clean LaTeX auxiliary files
61+
clean-latex:
62+
docker run --rm -v `pwd`/tex:/usr/src $(RUN_IMAGE) latexmk -C test.tex
5363

54-
# Remove all Docker images for this project (optional)
64+
# Remove local images
5565
clean-images:
56-
@if docker images | grep $(IMAGE_NAME); then \
57-
echo "Removing Docker images for $(IMAGE_NAME)..."; \
58-
docker rmi $(IMAGE_NAME):$(TAG) $(IMAGE_NAME):latest || true; \
59-
fi
66+
-docker rmi $(IMAGE_NAME):$(TAG) $(IMAGE_NAME):latest
6067

61-
# Convenience target for full reset: Cleanup, rebuild, and push
62-
reset: cleanup clean-latex build push
68+
.PHONY: def build buildx push push-legacy ssh tex pstricks check clean-latex clean-images

0 commit comments

Comments
 (0)