Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git
# ########################################################################
#
# Copyright 2022 White Magic Software, Ltd.
#
# Creates a container image that can run ConTeXt to typeset documents.
#
# ########################################################################

LABEL org.opencontainers.image.description Configures a typesetting system.

FROM alpine:latest
ENV ENV="/etc/profile"
ENV PROFILE=/etc/profile

ENV INSTALL_DIR=/opt
ENV SOURCE_DIR=/root/source
ENV TARGET_DIR=/root/target
ENV IMAGES_DIR=/root/images
ENV THEMES_DIR=/root/themes
ENV CACHES_DIR=/root/caches
ENV FONTS_DIR=/usr/share/fonts/user
ENV DOWNLOAD_DIR=/root

ENV CONTEXT_HOME=$INSTALL_DIR/context

# ########################################################################
#
# Download all required dependencies
#
# ########################################################################
WORKDIR $DOWNLOAD_DIR

# Carlito (Calibri replacement)
ADD "https://github.com/googlefonts/carlito/raw/main/fonts/ttf/Carlito-Regular.ttf" "Carlito-Regular.ttf"
ADD "https://github.com/googlefonts/carlito/raw/main/fonts/ttf/Carlito-Bold.ttf" "Carlito-Bold.ttf"
ADD "https://github.com/googlefonts/carlito/raw/main/fonts/ttf/Carlito-Italic.ttf" "Carlito-Italic.ttf"
ADD "https://github.com/googlefonts/carlito/raw/main/fonts/ttf/Carlito-BoldItalic.ttf" "Carlito-BoldItalic.ttf"

# Open Sans Emoji
ADD "https://github.com/MorbZ/OpenSansEmoji/raw/master/OpenSansEmoji.ttf" "OpenSansEmoji.ttf"

# Underwood Quiet Tab
ADD "https://site.xavier.edu/polt/typewriters/Underwood_Quiet_Tab.ttf" "Underwood_Quiet_Tab.ttf"

# Archives
ADD "https://www.omnibus-type.com/wp-content/uploads/Archivo-Narrow.zip" "archivo-narrow.zip"
ADD "https://fonts.google.com/download?family=Courier%20Prime" "courier-prime.zip"
ADD "https://fonts.google.com/download?family=Inconsolata" "inconsolata.zip"
ADD "https://fonts.google.com/download?family=Libre%20Baskerville" "libre-baskerville.zip"
ADD "https://fonts.google.com/download?family=Niconne" "niconne.zip"
ADD "https://fonts.google.com/download?family=Nunito" "nunito.zip"
ADD "https://fonts.google.com/download?family=Roboto" "roboto.zip"
ADD "https://fonts.google.com/download?family=Roboto%20Mono" "roboto-mono.zip"
ADD "https://github.com/adobe-fonts/source-serif/releases/download/4.004R/source-serif-4.004.zip" "source-serif.zip"

# Typesetting software
ADD "http://lmtx.pragma-ade.nl/install-lmtx/context-linuxmusl.zip" "context.zip"

# ########################################################################
#
# Install components, modules, configure system, remove unnecessary files
#
# ########################################################################
WORKDIR $CONTEXT_HOME

RUN \
  apk --update --no-cache \
    add ca-certificates curl fontconfig inkscape rsync && \
  mkdir -p \
    "$FONTS_DIR" "$INSTALL_DIR" \
    "$TARGET_DIR" "$SOURCE_DIR" "$THEMES_DIR" "$IMAGES_DIR" "$CACHES_DIR" && \
  echo "export CONTEXT_HOME=\"$CONTEXT_HOME\"" >> $PROFILE && \
  echo "export PATH=\"\$PATH:\$CONTEXT_HOME/tex/texmf-linuxmusl/bin\"" >> $PROFILE && \
  echo "export OSFONTDIR=\"/usr/share/fonts//\"" >> $PROFILE && \
  echo "PS1='\\u@typesetter:\\w\\$ '" >> $PROFILE && \
  unzip -d $CONTEXT_HOME $DOWNLOAD_DIR/context.zip && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/archivo-narrow.zip "Archivo-Narrow/otf/*.otf" && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/courier-prime.zip "*.ttf" && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/libre-baskerville.zip "*.ttf" && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/inconsolata.zip "**/Inconsolata/*.ttf" && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/niconne.zip "*.ttf" && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/nunito.zip "static/*.ttf" && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/roboto.zip "*.ttf" && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/roboto-mono.zip "static/*.ttf" && \
  unzip -j -o -d $FONTS_DIR $DOWNLOAD_DIR/source-serif.zip "source-serif-4.004/OTF/SourceSerif4-*.otf" && \
  mv $DOWNLOAD_DIR/*tf $FONTS_DIR && \
  fc-cache -f -v && \
  mkdir -p tex && \
  #rsync \
    #--recursive --links --times \
    #--info=progress2,remove,symsafe,flist,del \
    #--human-readable --del \
    #rsync://contextgarden.net/minimals/current/modules/ modules && \
  #rsync \
    #-rlt --exclude=/VERSION --del modules/*/ tex/texmf-modules && \
  sh install.sh && \
  rm -f $DOWNLOAD_DIR/*.zip && \
  rm -rf \
    "modules" \
    "/var/cache" \
    "/usr/share/icons" \
    $CONTEXT_HOME/tex/texmf-modules/doc \
    $CONTEXT_HOME/tex/texmf-context/doc && \
  mkdir -p $CONTEXT_HOME/tex/texmf-fonts/tex/context/user && \
  ln -s $CONTEXT_HOME/tex/texmf-fonts/tex/context/user $HOME/fonts && \
  source $PROFILE && \
  mtxrun --generate && \
  find \
    /usr/share/inkscape \
    -type f -not -iname \*.xml -exec rm {} \; && \
  find \
    $CONTEXT_HOME \
    -type f \
      \( -iname \*.pdf -o -iname \*.txt -o -iname \*.log \) \
    -exec rm {} \;

# ########################################################################
#
# Ensure login goes to the target directory. ConTeXt prefers to export to
# the current working directory.
#
# ########################################################################
WORKDIR $TARGET_DIR