惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
U
Unit 42
T
Tailwind CSS Blog
罗磊的独立博客
WordPress大学
WordPress大学
小众软件
小众软件
Recent Announcements
Recent Announcements
博客园 - 聂微东
Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
V
V2EX
博客园 - 三生石上(FineUI控件)
I
InfoQ
雷峰网
雷峰网
G
Google Developers Blog
阮一峰的网络日志
阮一峰的网络日志
B
Blog
腾讯CDC
A
About on SuperTechFans
博客园 - 叶小钗

John Bokma's Hacking and Hiking

Setting up a Brother AirPrinter on Ubuntu Failed to verify signature archive-contents.sig in Emacs Aquamacs 3.6 Hangs When Saving An Encrypted File PAR trouble How To Create a Bootable LibreELEC Installation using Mac OS A Docker Image for Sass Timezones in Alpine Docker Containers A Tale of Three Docker Images Debugging a Perl Docker container Perl Time::Piece Unicode Issue Giving Docker Desktop for macOS a Second Chance Flashing another TP-Link TL-WDR4300 with OpenWrt firmware Rehousing two tarantulas Getting started with the Perl version of tumblelog on Ubuntu 18.04 LTS A visit to Avonturia De Vogelkelder Flashing a TP-Link TL-WDR4300 with OpenWrt firmware Mounting a VDI File in a Different VirtualBox Guest Wireless Headless Raspberry Pi - John Bokma A Matter of Time - John Bokma Hand coding an RSS 2.0 feed in Python RFC #822 and RFC #3339 dates in Perl RFC #822 and RFC #3339 dates in Python Hand coding an RSS 2.0 feed in Perl Nav Element with no Heading Rewriting CommonMark Nodes in Perl "right" this time
Running pdflatex Using the Alpine Pandoc LaTeX Docker Image
John Bokma · 2021-06-19 · via John Bokma's Hacking and Hiking

June 20, 2021

I use a custom Perl script which uses pdflatex to generate invoices for my customers. Currently the program runs in a VirtualBox virtual machine (Ubuntu). But since I want to switch to Apple Silicon in the near future I am currently moving several programs to Docker. I was able to make the Perl program, after a few minor modifications, on macOS except for the external call to pdflatex. Since I want to reduce the number of programs I have to install directly on macOS I decided to "dockerize" pdflatex.

Because I want the Docker image to be small I started out with an Alpine image. But installing texlive-full resulted in an image of several gigabytes! After a few experiments I decided to see if I could just run pdflatex from a Pandoc Docker image I already needed for creating my resume.

$ docker run --rm --entrypoint pdflatex resume-pandoc
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021) (preloaded forma
t=pdflatex)
 restricted \write18 enabled.
**
! End of file on the terminal... why?

Because this image is "just" 686.6MB I decided to try to create a new image using pandoc-latex as a base:

# syntax=docker/dockerfile:1
FROM pandoc/latex:latest

ENTRYPOINT ["pdflatex"]

I build the Docker image using:

docker build -t pdflatex .

When running the container using:

docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pdflatex \
    invoice.tex

I got the following error message:

! LaTeX Error: File `sectsty.sty' not found.

Since I had seen the same error when building the image I use to create my resume I already knew the solution: install the missing package using tlmgr. So I updated the Dockerfile:

# syntax=docker/dockerfile:1
FROM pandoc/latex:latest

RUN tlmgr update --self && tlmgr install sectsty

ENTRYPOINT ["pdflatex"]

Running the newly created image resulted in another error:

! LaTeX Error: File `lastpage.sty' not found.

So I added this package as well, resulting in:

# syntax=docker/dockerfile:1
FROM pandoc/latex:latest

RUN tlmgr update --self && tlmgr install sectsty lastpage

ENTRYPOINT ["pdflatex"]

This time I got yet another error, but one that was a bit harder to fix:

! Font T1/phv/m/n/10=phvr8t at 10.0pt not loadable: Metric (TFM) file not found
.

A font was missing, but which one, and which package to install? Googling the error message gave a quick answer: helvetic. Adding this to the installation step resulted in a working image; I now could generate a PDF invoice from a TeX input file.

# syntax=docker/dockerfile:1
FROM pandoc/latex:latest

RUN tlmgr update --self && tlmgr install sectsty lastpage helvetic

ENTRYPOINT ["pdflatex"]