Skip to content

Commit

Permalink
Move class file to root
Browse files Browse the repository at this point in the history
Solves a nasty issue: previously, we relied on 'acp.cls'
to be available in the image, at a tex-wide installation directory.
This had the advantage of that class being available to any document
using the image, but it had a core disadvantage: modifying the class file
would require *rebuilding the image*, which is big no bueno.
So even adjusting just the font weight on the title page, for example,
would necessitate an image rebuild.

Now, the class file is at the project root. Here, it can be found
by latex *directly*.
In order to still bake it into the image, the Docker build process
needs to be changed slightly (the build context needs to be moved up
to the root directory to find acp.cls, since the build context
cannot move up directories).
This gets us the best of both worlds with only a slightly more
annoying Docker build process.

Users can now change the class file freely, and changes will be
reflected in their document immediately, no image rebuild
necessary.
  • Loading branch information
alexpovel committed May 30, 2022
1 parent be81b7b commit 6334b0c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// Instead of *building* the accompanying Dockerfile and its whole context, like:
//
// "build": {
// "dockerfile": "image/Dockerfile",
// "context": "..",
// "dockerfile": "image/Dockerfile"
// },
//
// simply download the prepared image the author has already uploaded, based on
Expand Down
10 changes: 7 additions & 3 deletions .devcontainer/image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ARG OS_VERSION="testing"
# For available years, see ftp:https://tug.org/historic/systems/texlive/ .
ARG TL_VERSION="latest"

ARG _BUILD_CONTEXT_PREFIX=".devcontainer/image/"

# Image with layers as used by all succeeding steps
FROM ${BASE_OS}:${OS_VERSION} as base

Expand Down Expand Up @@ -121,12 +123,13 @@ FROM base as downloads

# Renew (https://stackoverflow.com/a/53682110):
ARG TL_VERSION
ARG _BUILD_CONTEXT_PREFIX

ARG TL_INSTALL_ARCHIVE="install-tl-unx.tar.gz"
ARG EISVOGEL_ARCHIVE="Eisvogel.tar.gz"
ARG INSTALL_TL_DIR="install-tl"

COPY texlive.sh .
COPY ./${_BUILD_CONTEXT_PREFIX}/texlive.sh .

RUN \
# Get appropriate installer for the TeXLive version to be installed:
Expand All @@ -151,6 +154,7 @@ FROM base as main

# Renew (https://stackoverflow.com/a/53682110):
ARG TL_VERSION
ARG _BUILD_CONTEXT_PREFIX

ARG TL_PROFILE="texlive.profile"
# Auxiliary, intermediate file:
Expand Down Expand Up @@ -204,15 +208,15 @@ ARG INSTALL_DIR="/install"
WORKDIR ${INSTALL_DIR}

# Copy custom file containing TeXLive installation instructions
COPY config/${TL_PROFILE} ${TMP_TL_PROFILE}
COPY ${_BUILD_CONTEXT_PREFIX}/config/${TL_PROFILE} ${TMP_TL_PROFILE}
COPY --from=downloads /install-tl/ /texlive.sh ./

# Move to where pandoc looks for templates, see https://pandoc.org/MANUAL.html#option--data-dir
COPY --from=downloads /eisvogel.latex /home/${USER}/.pandoc/templates/

# Global wget config file, see the comments in that file for more info and the rationale.
# Location of that file depends on system, e.g.: https://askubuntu.com/a/368050
COPY config/.wgetrc /etc/wgetrc
COPY ${_BUILD_CONTEXT_PREFIX}/config/.wgetrc /etc/wgetrc

# "In-place" `envsubst` run is a bit more involved, see also:
# https://stackoverflow.com/q/35078753/11477374.
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# The following are "special targets", see:
# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#Special-Targets
# A phony target: not a file, just some routine.
.PHONY: all clean mostlyclean clean-aux clean-pdf tex preflight help
.PHONY: all clean mostlyclean clean-aux clean-pdf tex preflight help image

# =====================================================================================
# Helper tool, adjusted from:
Expand Down Expand Up @@ -165,6 +165,13 @@ preflight: # Performs checks to ensure prerequisites for compilation are met.
# Output looks like: https://tex.stackexchange.com/a/311753/120853
@$(LATEXMK) --commands

# =====================================================================================
# Docker
# =====================================================================================

image: ./.devcontainer/image/Dockerfile
@docker build --tag alexpovel/latex:local --file $< .

# =====================================================================================
# Testing.
# =====================================================================================
Expand Down
File renamed without changes.

0 comments on commit 6334b0c

Please sign in to comment.