Add automated LaTeX manual build (refs #12)
Automated Manual Build / manual (push) Successful in 1m27s

This commit is contained in:
2026-10-07 18:56:18 -04:00
parent d4d3c02f05
commit 828f6c555b
70 changed files with 7226 additions and 1 deletions
+12
View File
@@ -0,0 +1,12 @@
# TeX Live compiler image: compiles a mounted .tex file to PDF, then exits.
FROM debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
texlive-latex-base texlive-latex-recommended \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /work
ENTRYPOINT ["pdflatex", "-interaction=nonstopmode", "-halt-on-error"]
CMD ["sample.tex"]
@@ -0,0 +1,61 @@
$ErrorActionPreference = 'Stop'
$projectDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
$dockerCommand = Get-Command docker -ErrorAction SilentlyContinue
if ($dockerCommand) {
$docker = $dockerCommand.Source
} else {
$candidates = @(
(Join-Path $env:LOCALAPPDATA 'Programs\DockerDesktop\resources\bin\docker.exe'),
(Join-Path $env:ProgramFiles 'Docker\Docker\resources\bin\docker.exe')
)
$docker = $candidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
}
if (-not $docker) { throw 'Docker was not found. Start Docker Desktop and retry.' }
$buildLog = Join-Path $projectDirectory 'docker-build.log'
$runLog = Join-Path $projectDirectory 'docker-run.log'
$pdfPath = Join-Path $projectDirectory 'sample.pdf'
Push-Location $projectDirectory
try {
$engineVersion = (& $docker info --format '{{.ServerVersion}}' 2>$null).Trim()
if ($LASTEXITCODE -ne 0) { throw 'Docker Desktop is not ready.' }
Write-Host '> docker build --no-cache -t latex-docker .'
$ErrorActionPreference = 'Continue'
& $docker build --no-cache --progress=plain -t latex-docker . *> $buildLog
$ErrorActionPreference = 'Stop'
if ($LASTEXITCODE -ne 0) {
Get-Content -LiteralPath $buildLog -Tail 25
throw "Image build failed. Full output: $buildLog"
}
$imageId = (& $docker image inspect --format '{{.Id}}' latex-docker).Trim()
if ($LASTEXITCODE -ne 0 -or -not $imageId) { throw 'Built image could not be inspected.' }
Write-Host '> docker run --rm -v "${PWD}:/work" latex-docker'
$runStarted = Get-Date
$ErrorActionPreference = 'Continue'
& $docker run --rm -v "${PWD}:/work" latex-docker *> $runLog
$ErrorActionPreference = 'Stop'
if ($LASTEXITCODE -ne 0) {
Get-Content -LiteralPath $runLog -Tail 25
throw "LaTeX compilation failed. Full output: $runLog"
}
$pdf = Get-Item -LiteralPath $pdfPath -ErrorAction Stop
$runText = Get-Content -LiteralPath $runLog -Raw
if ($pdf.LastWriteTime -lt $runStarted.AddSeconds(-2) -or
$runText -notmatch 'Output written on sample\.pdf \((\d+) page') {
throw "A fresh, successful sample.pdf was not confirmed. See $runLog"
}
$pages = $matches[1]
Write-Host "Docker engine: $engineVersion"
Write-Host "Built image: latex-docker ($($imageId.Substring(0, 19)))"
Write-Host "Compiled PDF: sample.pdf ($pages page, $($pdf.Length) bytes)"
Write-Host 'Full output saved: docker-build.log, docker-run.log'
}
finally {
Pop-Location
}
+37
View File
@@ -0,0 +1,37 @@
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\title{Hello from a Docker Container}
\author{SSW 590 Group 1}
\date{\today}
\begin{document}
\maketitle
\section{Purpose}
This document was compiled by \texttt{pdflatex} from TeX Live running inside
a Docker container, the same idea Overleaf uses to compile projects in
isolated environments.
\section{Sample Content}
\begin{itemize}
\item Lists, sections, and a title block.
\item Mathematics: $e^{i\pi} + 1 = 0$ and
\begin{equation}
\sum_{k=1}^{n} k = \frac{n(n+1)}{2}.
\end{equation}
\item A table:
\end{itemize}
\begin{center}
\begin{tabular}{|l|l|}
\hline
Tool & Role \\ \hline
Docker & Container runtime \\
TeX Live & LaTeX distribution \\
pdflatex & Compiler \\ \hline
\end{tabular}
\end{center}
\end{document}