Skip to content

engineervix/docker-python-latex

Repository files navigation

python-latex

Build Docker images Publish Docker images

A Docker image to ease building Python applications that depend on LaTeX

Features

  • Python 3.8 - 3.12, based on the official slim-* images, where * includes:
    • bullseye
    • bookworm
  • LaTeX environment with texlive-full
  • Pandoc for converting from one markup format to another

Usage

Pulling the Image

You can pull the pre-built image from Docker Hub:

docker pull engineervix/python-latex:3.12-slim-bookworm

Replace 3.12 and bookworm with the desired Python version and Debian release, respectively.

Running a Container

To run a container using the image:

docker run -it --rm engineervix/python-latex:3.12-slim-bookworm

This will start an interactive shell inside the container.

Building a Container with Your Application

Here's an example of a Dockerfile for your Python application:

FROM engineervix/python-latex:3.12-slim-bookworm

WORKDIR /app

# Copy your application files
COPY . /app

# Install any necessary dependencies
RUN pip install -r requirements.txt

# Command to run your application
CMD ["python", "your_script.py"]

Build and run your container:

docker build -t my-python-latex-app .
docker run -it --rm my-python-latex-app

Using LaTeX and Pandoc

You can directly use LaTeX and Pandoc commands within the container. For example, to convert a Markdown file to a PDF:

  1. Start a container and mount your current directory:
docker run -it --rm -v $(pwd):/workspace -w /workspace engineervix/python-latex:3.12-slim-bookworm
  1. Inside the container, use Pandoc to convert your file:
pandoc input.md -o output.pdf

Or compile a LaTeX document:

pdflatex document.tex