From ada792aa2f3e202d55fb32ca4587ce9639b8afc2 Mon Sep 17 00:00:00 2001
From: Malin Freeborn <malinfreeborn@posteo.net>
Date: Tue, 23 Jan 2024 21:34:38 +0100
Subject: [PATCH] allow for docker pdf compilation

---
 Docker/Dockerfile |  2 ++
 Docker/README.md  | 21 +++++++++++++++++++--
 Docker/gimme      | 29 +++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)
 create mode 100755 Docker/gimme

diff --git a/Docker/Dockerfile b/Docker/Dockerfile
index c3bd2925..b5b8ec4c 100644
--- a/Docker/Dockerfile
+++ b/Docker/Dockerfile
@@ -6,6 +6,8 @@ COPY x-install.sh /
 
 COPY tlmgrDeps.sh /
 
+COPY gimme /usr/bin/
+
 RUN /x-install.sh
 
 ENV PATH="/opt/texlive/2023/bin/x86_64-linux:${PATH}"
diff --git a/Docker/README.md b/Docker/README.md
index 9ca911fc..7d5cc455 100644
--- a/Docker/README.md
+++ b/Docker/README.md
@@ -1,8 +1,25 @@
-These files make up the docker which runs the BIND CI line.
-If you want to change things and upload them, you'll need to sign up to docker.com and use your own username.
+These files create the docker container which runs the BIND CI line.
+
+### Compiling with this image
+
+List any of the existing BIND books in a variable, then build them in a container:
+
+```bash
+books="core stories mim"
+docker run -it --rm --name texbooks andonome/texbind:latest gimme $books
+```
+
+Copy the files from the container:
+
+```bash
+docker cp -a texbooks:BIND .
+```
+
+### Make a new image
 
 ```bash
 docker login
 docker build -t $USERNAME/texbind .
 docker push $USERNAME/texbind
 ```
+...then change the CI file to match your username.
diff --git a/Docker/gimme b/Docker/gimme
new file mode 100755
index 00000000..a1dda014
--- /dev/null
+++ b/Docker/gimme
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# This script clones and comples BIND books.
+
+set -e
+
+mkdir -p /BIND/
+
+for b in $@; do
+    git clone https://gitlab.com/bindrpg/$b
+    make -C $b all
+done
+
+# The second compilation means the cross-references should work.
+
+for n in 1 2; do
+    for b in $@; do
+        make -C $b all
+    done
+done
+
+cp **/*.pdf /BIND/
+
+echo -e '\n\n\nCopy your files over by opening a new terminal, and running:\n\n'
+sleep 1
+echo 'docker cp -a texbooks:BIND .'
+sleep 4
+echo 'Once done, press the return key'
+read x
-- 
GitLab