Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Reduces RUN commands

Author DaveJarvis <email>
Date 2022-12-15 18:18:06 GMT-0800
Commit fdf49ef30025bd7cc83c57c2eea51e572f3de311
Parent f97d7c0
container/Containerfile
FROM alpine:latest
ENV ENV="/etc/profile"
-
-RUN apk --update add --no-cache fontconfig curl
-RUN rm -rf /var/cache
-
-# ########################################################################
-#
-# Configure environment variables
-#
-# ########################################################################
ENV PROFILE=/etc/profile
ENV CONTEXT_HOME=/opt/context
-RUN echo "export CONTEXT_HOME=\"$CONTEXT_HOME\"" >> $PROFILE
-RUN echo "export PATH=\"\$PATH:\$CONTEXT_HOME/tex/texmf-linuxmusl/bin\"" >> $PROFILE
-RUN echo "export OSFONTDIR=\"/usr/share/fonts//\""
-RUN echo "PS1='\\u@typesetter:\\w\\$ '" >> $PROFILE
+ENV FONT_DIR=/usr/share/fonts/user
+ENV DOC_DIR=/root/text
+ENV IMAGE_DIR=/root/images
+ENV THEME_DIR=/root/themes
+ENV INSTALL_DIR=/opt
+
+RUN \
+ apk --update add --no-cache fontconfig curl && \
+ mkdir -p "$FONT_DIR" "$DOC_DIR" "$IMAGE_DIR" "$THEME_DIR" "$INSTALL_DIR"
# ########################################################################
#
# Download and install fonts
#
# ########################################################################
-ENV FONT_DIR=/usr/share/fonts/user
-RUN mkdir -p $FONT_DIR
WORKDIR $FONT_DIR
ADD "https://github.com/adobe-fonts/source-serif/releases/download/4.004R/source-serif-4.004.zip" "source-serif.zip"
ADD "https://www.omnibus-type.com/wp-content/uploads/Archivo-Narrow.zip" "archivo-narrow.zip"
-
-# Unpack fonts
-RUN unzip -j -o courier-prime.zip "*.ttf"
-RUN unzip -j -o inconsolata.zip "**/Inconsolata/*.ttf"
-RUN unzip -j -o nunito.zip "static/*.ttf"
-RUN unzip -j -o roboto.zip "*.ttf"
-RUN unzip -j -o roboto-mono.zip "static/*.ttf"
-RUN unzip -j -o source-serif.zip "source-serif-4.004/OTF/SourceSerif4-*.otf"
-RUN unzip -j -o archivo-narrow.zip "Archivo-Narrow/otf/*.otf"
-RUN rm -f *.zip
-# Update system font cache
-RUN fc-cache -f -v
+# Unpack fonts, update system font cache
+RUN \
+ unzip -j -o courier-prime.zip "*.ttf" && \
+ unzip -j -o inconsolata.zip "**/Inconsolata/*.ttf" && \
+ unzip -j -o nunito.zip "static/*.ttf" && \
+ unzip -j -o roboto.zip "*.ttf" && \
+ unzip -j -o roboto-mono.zip "static/*.ttf" && \
+ unzip -j -o source-serif.zip "source-serif-4.004/OTF/SourceSerif4-*.otf" && \
+ unzip -j -o archivo-narrow.zip "Archivo-Narrow/otf/*.otf" && \
+ fc-cache -f -v
# ########################################################################
#
-# Download and extract themes
+# Configure environment variables
#
# ########################################################################
-WORKDIR "/opt"
-
-ADD "https://github.com/DaveJarvis/keenwrite-themes/releases/latest/download/theme-pack.zip" "theme-pack.zip"
-RUN unzip theme-pack.zip
-RUN rm theme-pack.zip
+RUN \
+ echo "export CONTEXT_HOME=\"$CONTEXT_HOME\"" >> $PROFILE && \
+ echo "export PATH=\"\$PATH:\$CONTEXT_HOME/tex/texmf-linuxmusl/bin\"" >> $PROFILE && \
+ echo "export OSFONTDIR=\"/usr/share/fonts//\"" && \
+ echo "PS1='\\u@typesetter:\\w\\$ '" >> $PROFILE
# ########################################################################
#
# Download and install typesetting software
#
# ########################################################################
+WORKDIR $INSTALL_DIR
+
ADD "http://lmtx.pragma-ade.nl/install-lmtx/context-linuxmusl.zip" "context.zip"
RUN unzip context.zip -d context
-RUN rm -f context.zip
WORKDIR "context"
RUN sh install.sh
-# Remove unnecessary files
-RUN rm -rf $CONTEXT_HOME/tex/texmf-context/doc
-RUN find . -type f -name "*.pdf" -exec rm {} \;
-RUN find . -type f -name "*.log" -exec rm {} \;
+# ########################################################################
+#
+# Download and extract themes
+#
+# ########################################################################
+WORKDIR $THEME_DIR
-# Prepare to process text files
-WORKDIR "/root"
+ADD "https://github.com/DaveJarvis/keenwrite-themes/releases/latest/download/theme-pack.zip" "theme-pack.zip"
+RUN unzip theme-pack.zip
-RUN mkdir -p "text"
-RUN mkdir -p "images"
+# ########################################################################
+#
+# Remove unnecessary files
+#
+# ########################################################################
+RUN \
+ rm -rf "/var/cache" && \
+ rm -rf "$CONTEXT_HOME/tex/texmf-context/doc" && \
+ rm -f "$THEME_DIR/theme-pack.zip" && \
+ rm -f "$FONT_DIR/*.zip" && \
+ rm -f "$INSTALL_DIR/context.zip" && \
+ find . -type f -name "*.pdf" -exec rm {} \; && \
+ find . -type f -name "*.log" -exec rm {} \;
container/manage.sh
"c,connect,Connect to container"
"d,delete,Remove all containers"
- "i,images,Set image files mount point"
+ "i,images,Set mount point for image files (to typeset)"
"l,load,Load container (${CONTAINER_COMPRESSED_PATH})"
"r,run,Run a command in the container (\"${ARG_CONTAINER_COMMAND}\")"
"s,save,Save container (${CONTAINER_COMPRESSED_PATH})"
- "t,text,Set text file mount point (to typeset)"
+ "t,text,Set mount point for text file (to typeset)"
)
# ---------------------------------------------------------------------------
-# Manages the container image.
+# Manages the container.
# ---------------------------------------------------------------------------
execute() {
# ---------------------------------------------------------------------------
-# Deletes all container images.
+# Deletes all containers.
# ---------------------------------------------------------------------------
utile_delete() {
- $log "Deleting all images"
+ $log "Deleting all containers"
${CONTAINER_EXE} rmi --all --force > /dev/null
- $log "Images deleted"
+ $log "Containers deleted"
}
Delta 54 lines added, 48 lines removed, 6-line increase