|
1 | 1 | # 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 |
4 | 5 |
|
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 |
8 | 8 |
|
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 |
12 | 11 |
|
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 |
17 | 14 |
|
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 |
21 | 18 |
|
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 |
28 | 23 |
|
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 |
32 | 33 |
|
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 |
36 | 37 |
|
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 |
40 | 42 |
|
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' |
46 | 59 |
|
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 |
53 | 63 |
|
54 | | -# Remove all Docker images for this project (optional) |
| 64 | +# Remove local images |
55 | 65 | 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 |
60 | 67 |
|
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