MiKTeX / docker-miktex

the Docker image for running MiKTeX
41 stars 28 forks source link

Manually installing packages #41

Closed moemode closed 9 months ago

moemode commented 9 months ago

Hi all,

im trying to use the docker image for https://github.com/latextemplates/scientific-thesis-template. Somehow the automatic install does not work for currfile and dehyph-exptl. Upon fail of the first run of latexmk, the following fixes the missing packages

docker run -ti -v miktex:/var/lib/miktex -v `pwd`:/miktex/work -e MIKTEX_UID=`id -u` miktex/miktex:basic  mpm --install=currfile
docker run -ti -v miktex:/var/lib/miktex -v `pwd`:/miktex/work -e MIKTEX_UID=`id -u` miktex/miktex:basic  mpm --install=dehyph-exptl

Now i would like to automate that and have provided my own entrypoint.sh. It actually gets executed and seems to install the packages. Despite this, when i try to latexmk I get the error that the currfile package is missing. The manually run commands fix the issue, but the install in the entrypoint has no effect. Does anyone know why?

# Use the base MiKTeX image
FROM miktex/miktex:basic
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
#!/bin/bash

MIKTEX_UID=${MIKTEX_UID:-1000}
MIKTEX_GID=${MIKTEX_GID:-${MIKTEX_UID}}
if [ "$(id -u miktex)" != 1000 ]; then
    usermod -u ${MIKTEX_UID} miktex >/dev/null
    groupmod -g ${MIKTEX_GID} miktex
    chown -R miktex:miktex /var/lib/miktex
fi

CONTAINER_ALREADY_STARTED="/var/lib/miktex/started_before"
if [ ! -e $CONTAINER_ALREADY_STARTED ]; then
    touch $CONTAINER_ALREADY_STARTED
    echo "-- First container startup --"
    # Install MiKTeX packages
    mpm --install=dehyph-exptl
    mpm --install=currfile
else
    echo "-- Not first container startup --"
fi

# Execute the command passed to the entrypoint
exec gosu miktex "$@"
moemode commented 9 months ago

The solution was to run mpm as user miktex

#!/bin/bash

MIKTEX_UID=${MIKTEX_UID:-1000}
MIKTEX_GID=${MIKTEX_GID:-${MIKTEX_UID}}
if [ "$(id -u miktex)" != 1000 ]; then
    usermod -u ${MIKTEX_UID} miktex >/dev/null
    groupmod -g ${MIKTEX_GID} miktex
    chown -R miktex:miktex /var/lib/miktex
fi

CONTAINER_ALREADY_STARTED="/var/lib/miktex/started_before"
if [ ! -e $CONTAINER_ALREADY_STARTED ]; then
    touch $CONTAINER_ALREADY_STARTED
    echo "-- First container startup --"
    # Install MiKTeX packages
    gosu miktex mpm --install=dehyph-exptl
    gosu miktex mpm --install=currfile
else
    echo "-- Not first container startup --"
fi

# Execute the command passed to the entrypoint
exec gosu miktex "$@"