pandoc / dockerfiles

Dockerfiles for various pandoc images
GNU General Public License v2.0
371 stars 100 forks source link

Option for more complete texlive? #81

Closed jdossgollin closed 6 months ago

jdossgollin commented 4 years ago

I'm trying to use pandoc/latex:2.6 to convert markdown to PDF. I had in mind to use the eisvogel template, which requires a fairly complete latex distribution (in the meantime I can use another more basic template, but this would be helpful). In particular, missingfootnotebackref.sty is the first error message that I get. Is there a way to create an image that uses a more full version of texlive? I looked through the alpine latex dockerfile and couldn't find an easy way to change from texlive to texlive-full (or something along those lines).

tarleb commented 4 years ago

Not sure about images based on the official ones, but there is https://github.com/survivorbat/pandoc-eisvogel-image/, which I'd describe as the next best thing.

Ricq commented 4 years ago

What works for me is baking my own derivate image using a Dockerfile like:

# Disabled next line in favor of fix on line beneath it, since pandoc/latest isn't updated for
# TexLive 2020 yet (rick; 2020-04-17). Re-enable once pandoc/latex is up to date.
# See https://github.com/pandoc/dockerfiles/issues/82
#
# FROM pandoc/latex:latest
FROM registry.gitlab.com/savadenn-public/pandoc-latex-rebuilt:latest

# Update Alpine and install tools
RUN apk upgrade --update && apk add --no-cache --update bash

# Install additional fonts
RUN apk add --no-cache --update font-noto

# Add UTF-8 locales
RUN apk --no-cache add ca-certificates wget && \
    wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-bin-2.29-r0.apk && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-i18n-2.29-r0.apk && \
    apk add glibc-2.29-r0.apk glibc-bin-2.29-r0.apk glibc-i18n-2.29-r0.apk

## Note that locale -a is not available in alpine linux, use `/usr/glibc-compat/bin/locale -a` instead
RUN /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
RUN /usr/glibc-compat/bin/localedef -i nl_NL -f UTF-8 nl_NL.UTF-8

ENV LANG=en_US.UTF-8 \
    LANGUAGE=en_US.UTF-8

# Install additional Latex packages
RUN tlmgr update --self
RUN tlmgr update --all
RUN tlmgr install mdframed \
                  needspace \
                  sourcesanspro \
                  sourcecodepro \
                  titling \
                  pagecolor \
                  adjustbox \
                  collectbox \
                  zref \
                  footnotebackref

WORKDIR /data
ENTRYPOINT ["/bin/bash"]
CMD ["/data/build.sh"]

and then baking the image using commands such as:

docker image pull pandoc/latex
docker build --file build/Dockerfile --tag my-image .
blaggacao commented 4 years ago

@Ricq Why the locales section? Should it be necesary, it should go directly in here, woudn't it?

Ricq commented 4 years ago

I remember wanting to use some specific Unicode characters and my source files being UTF-8, which resulted in build errors. Alpine doesn't support changing the locale to set UTF-8 out of the box. After some searching I found this solution. It's a pretty common solution if you search for locale on Alpine Linux.

A slight variation, which I would now implement, iterates through a list of locales in a file: https://gist.github.com/Herz3h/0ffc2198cb63949a20ef61c1d2086cc0

It would be useful if it was included here, but unsure of the maintenance that brings. First, which locales would you include? And what happens if the musl-glibc updates? Would it interact with other things users do?

blaggacao commented 4 years ago

Looks like so muslibc doesn support POSIX localdef: http://www.etalabs.net/compare_libcs.html

Going by https://gist.github.com/Herz3h/0ffc2198cb63949a20ef61c1d2086cc0 is the cost huge to include all of them? I think they potentially don't outweigh the benefit of "just works tm"...

From official musl docs (https://musl.libc.org/doc/1.1.24/manual.html):

LC_ALL, LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, and LANG - Used by setlocale and newlocale to determine a locale name to use when a zero-length string is passed. The precedence rules follow POSIX: LC_ALL overrides category-specific variables, and LANG provides a default for any category not set.

MUSL_LOCPATH - Colon-separated list of paths that will be searched for locale definitions. The requested locale name string will used as a filename and searched in each path component. If unset, locale files are not loaded and only the "C" locale is available. This variable is completely ignored in programs invoked setuid, setgid, or with other elevated capabilities.

Based on which there is: https://grrr.tech/posts/2020/add-locales-to-alpine-linux-docker-image/

Looks like the glibc workarround has more languages...

tarleb commented 6 months ago

We now have pandoc/extra images, those also include the Eisvogel template.