Skip to content

Commit

Permalink
23.10 essential, basic
Browse files Browse the repository at this point in the history
  • Loading branch information
edocevoli committed Oct 6, 2023
1 parent c0960fd commit 8008379
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 65 deletions.
46 changes: 30 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,56 @@
FROM ubuntu:focal
FROM ubuntu:jammy

LABEL Description="Dockerized MiKTeX, Ubuntu 22.04" Vendor="Christian Schenk" Version="23.4"
LABEL Description="Dockerized MiKTeX, Ubuntu 22.04"
LABEL Vendor="Christian Schenk"
LABEL Version="23.10.5"

ARG DEBIAN_FRONTEND=noninteractive

ARG user=miktex
ARG group=miktex
ARG uid=1000
ARG gid=1000

ARG miktex_home=/var/lib/miktex
ARG miktex_work=/miktex/work

RUN groupadd -g ${gid} ${group} \
&& useradd -d "${miktex_home}" -u ${uid} -g ${gid} -m -s /bin/bash ${user}

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
curl \
dirmngr \
ghostscript \
gnupg \
gosu \
make \
perl

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D6BC243565B2087BC3F897C9277A7293F59E4889
RUN echo "deb http://miktex.org/download/ubuntu jammy universe" | tee /etc/apt/sources.list.d/miktex.list
RUN curl -fsSL https://miktex.org/download/key | tee /usr/share/keyrings/miktex-keyring.asc > /dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/miktex-keyring.asc] https://miktex.org/download/ubuntu jammy universe" | tee /etc/apt/sources.list.d/miktex.list

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
miktex

USER ${user}

RUN miktexsetup finish \
&& initexmf --admin --set-config-value=[MPM]AutoInstall=1 \
&& mpm --admin --update-db \
&& mpm --admin \
--install amsfonts \
--install biber-linux-x86_64 \
&& initexmf --admin --update-fndb
&& initexmf --set-config-value=[MPM]AutoInstall=1 \
&& miktex packages update \
&& miktex packages install amsfonts

VOLUME [ "${miktex_home}" ]

WORKDIR ${miktex_work}

USER root

COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]

ENV MIKTEX_USERCONFIG=/miktex/.miktex/texmfs/config
ENV MIKTEX_USERDATA=/miktex/.miktex/texmfs/data
ENV MIKTEX_USERINSTALL=/miktex/.miktex/texmfs/install

WORKDIR /miktex/work
ENV PATH=/var/lib/miktex/bin:${PATH}

CMD ["bash"]
7 changes: 7 additions & 0 deletions Dockerfile.basic
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM miktex/miktex:latest

LABEL Description="Dockerized MiKTeX, Ubuntu 22.04"
LABEL Vendor="Christian Schenk"
LABEL Version="23.10.6"

RUN mpm --package-level=basic --upgrade
69 changes: 29 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,50 @@

This image allows you to run MiKTeX on any computer that supports Docker.

## Obtaining the image
## Example

Get the latest image from the registry:
Provided that your main input file is located in the current working directory,
you can run `pdflatex` as follows:

docker pull miktex/miktex
```sh
docker run -ti -v miktex:/var/lib/miktex -v `pwd`:/miktex/work -e MIKTEX_UID=`id -u` miktex/miktex:essential \
pdflatex main.tex
```

or build it yourself:
## Tags

docker build --tag miktex/miktex .
- 23.10-essential, essential (essential variant)
- 23.10-basic, basic (basic variant)

## Using the image
## Essential variant

### Volumes
The essential variant contains a bare MiKTeX system.

#### Input files
## Basic variant

The host directory containing the input files must be mounted to the
container path `/miktex/work`.
The basic variant contains the basic package set.

To mount the current host working directory, you would pass option `-v
$(pwd):/miktex/work` to the Docker `run` command.
## Volumes

#### Package files
### MiKTeX files

The container image contains a bare MiKTeX setup and MiKTeX is
configured to install missing package files in the container directory
`/miktex/.miktex`. It is recommended that you mount this directory to
a dedicated Docker volume.
MiKTeX is configured to install missing package files in the container directory
`/var/lib/miktex`.

### Running as `root` or not
It is recommended that you mount this directory to a named Docker volume. This
ensures that data (such as downloaded packages) survives the container.

By default, all commands inside the container are executed as `root`.
### Input files

It is possible to execute as a dedicated host user by
setting the container environment variables `MIKTEX_GID` and `MIKTEX_UID`.
The host directory containing the input files must be mounted to the container
path `/miktex/work`.

To execute as the current user, you would pass options `-e MIKTEX_GID=$(id
-g)` and `-e MIKTEX_UID=$(id -u)` to the Docker `run` command.
## User `miktex`

### Example
All commands inside the container are executed as user `miktex` and uid 1000.

First, create a Docker volume named `miktex`:
It is possible to change the uid by setting the container environment variable
`MIKTEX_UID`.

docker volume create --name miktex

This volume will be used to mount the the container directory
`/miktex/.miktex` in subsequent runs.

Provided that your main input file is located in the current working
directory, you can run `pdflatex` as follows:

docker run --rm -ti \
-v miktex:/miktex/.miktex \
-v $(pwd):/miktex/work \
-e MIKTEX_GID=$(id -g) \
-e MIKTEX_UID=$(id -u) \
miktex/miktex \
pdflatex main.tex
To execute as the current user, you would pass option `-e MIKTEX_UID=$(id -u)`
to the Docker `run` command.
16 changes: 7 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/bin/bash

if [ -z "${MIKTEX_UID}" ]; then
exec "$@"
else
MIKTEX_GID=${MIKTEX_GID:-${MIKTEX_UID}}
groupadd -g "${MIKTEX_GID}" -o miktex
useradd --shell /bin/bash -u "${MIKTEX_UID}" -g "${MIKTEX_GID}" -o -c "" -Md /miktex miktex
mkdir -p /miktex/.miktex
chown -R miktex:miktex /miktex/.miktex
exec gosu miktex "$@"
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
exec gosu miktex "$@"

0 comments on commit 8008379

Please sign in to comment.