Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
adjust Dockerfile, deps, readme, scripts, fonts. Latex workflow works.
  • Loading branch information
EsGeh authored and EsGeh committed Nov 15, 2019
1 parent 61b0637 commit 381b325
Show file tree
Hide file tree
Showing 14 changed files with 251 additions and 78 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
@@ -0,0 +1,2 @@
/scripts/
/env
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
/input/
/output/
/dependencies/
examples

# Byte-compiled / optimized / DLL files
Expand Down
89 changes: 85 additions & 4 deletions Dockerfile
@@ -1,24 +1,105 @@
FROM python:3
FROM python:3.8-buster

ENV PYTHONUNBUFFERED 1
ENV SHELL /bin/bash

ENV HOME_DIR /eoa/skripts


RUN sed -i "s#deb http://deb.debian.org/debian buster main#deb http://deb.debian.org/debian buster main contrib non-free#g" /etc/apt/sources.list
# sed -i "s#deb http://http.us.debian.org/debian jessie main contrib non-free#deb http://http.us.debian.org/debian jessie main contrib non-free#g" /etc/apt/sources.list

# add package source 'contrib':
# RUN echo "deb http://deb.debian.org/debian buster main contrib non-free" >> /etc/apt/sources.list
# RUN echo "deb-src http://deb.debian.org/debian buster main contrib non-free" >> /etc/apt/sources.list

# ------------------------------------------
# install necessary packages via apt-get:
# ------------------------------------------
RUN apt-get update && \
apt-get install -y --no-install-recommends \
RUN apt-get update && apt-get install -y --no-install-recommends \
graphicsmagick \
pandoc \
pandoc-citeproc \
curl \
biber

# install latex:
RUN apt-get update && apt-get install -y --no-install-recommends \
texlive-xetex

# install fonts:
RUN apt-get update && apt-get install -y --no-install-recommends \
texlive-fonts-extra \
ttf-mscorefonts-installer \
msttcorefonts \
fonts-lmodern \
fonts-noto-cjk \
texlive-lang-chinese \
texlive-science \
texlive-bibtex-extra \
tex-gyre

# install fonts:
RUN cp -r \
/usr/share/texlive/texmf-dist/fonts/opentype/public/xits \
/usr/local/share/fonts/

RUN fc-cache -f

RUN apt-get update && apt-get install -y --no-install-recommends \
less

# install fonts:
RUN apt-get update && apt-get install -y --no-install-recommends \
tralics

# needed for 'pdfcrop':
RUN apt-get update && apt-get install -y --no-install-recommends \
texlive-extra-utils

RUN apt-get update && apt-get install -y --no-install-recommends \
tex4ht

RUN apt-get update && apt-get install -y --no-install-recommends \
tidy

RUN apt-get update && apt-get install -y --no-install-recommends \
ghostscript

# install latex:
RUN apt-get update && apt-get install -y --no-install-recommends \
default-jre

# this is supposed to save memory:
RUN rm -rf /var/lib/apt/lists/*

# ------------------------------------------
# directories for manual installations:
# ------------------------------------------

ENV INSTALL_DIR "/eoa/install"
RUN mkdir -p "$INSTALL_DIR/"
ENV BIN_DIR "/eoa/bin"
RUN mkdir -p "$BIN_DIR/"
ENV PATH $BIN_DIR:$PATH

# ------------------------------------------
# install python dependencies:
# ------------------------------------------

WORKDIR ${INSTALL_DIR}
COPY requirements.txt "$INSTALL_DIR/"
RUN pip install -r requirements.txt
RUN pip install -r "requirements.txt"

# ------------------------------------------
# manual installations:
# ------------------------------------------

# install saxon
# Debians version of saxon is too old. We need to download it "manually" :-P
WORKDIR ${INSTALL_DIR}
RUN wget 'https://sourceforge.net/projects/saxon/files/Saxon-HE/9.6/SaxonHE9-6-0-10J.zip'
RUN unzip -d "$BIN_DIR" "SaxonHE9-6-0-10J.zip"
WORKDIR ${BIN_DIR}
RUN echo 'java -jar $BIN_DIR/saxon9he.jar "$@"' > $BIN_DIR/saxon
RUN chmod ugo+x $BIN_DIR/saxon
49 changes: 42 additions & 7 deletions README.md
Expand Up @@ -60,16 +60,51 @@ Docker images are not deleted though.
# Workflows

Compiling your documents involves following a workflow which can consist of several steps.
For all further explanations we assume you are in the docker container.

## The LaTeX workflow (TODO)
## The LaTeX workflow (eoatex -> pdf, django, epub)

TODO
1. load environment variables (just for convenience):

## The DocX workflow (TODO)
$ source .env

TODO
This step will make available the environment variables from `.env`, such as `$INPUT_DIR`.

## Examplary workflow (TODO)
1. copy your publication into the `$INPUT_DIR`

TODO
$ mkdir temp
$ cd temp
$ git clone 'https://github.molgen.mpg.de/EditionOpenAccess/eoa-publication-model.git'
$ cd eoa-publication-model
$ git checkout b40c1606d033fae8e1db9d989881caa1a47e2984
$ cd ../..
$ mkdir --parents $INPUT_DIR/example
$ cp -r "temp/eoa-publication-model/examples/eoatex" "$INPUT_DIR/example/eoatex"

1. enter the docker container

$ ./scripts/run.py # run if not yet running
$ ./scripts/exec_in_container.py # enter container

1. eoatex -> pdf

$ ./eoatex2pdf.py -f $INPUT_DIR/example/eoatex/EOASample.tex

(adjust filename if necessary)

1. eoatex -> imxml (convert to "intermediate xml")

$ ./eoatex2pdf.py -f $INPUT_DIR/example/eoatex/EOASample.tex

(adjust filename if necessary)

1. imxml -> django

$ ./imxml2django.py --publication-dir $INPUT_DIR/example/eoatex

1. imxml -> epub

$ ./imxml2epub.py --publication-dir $INPUT_DIR/example/eoatex

## The DocX workflow (docx -> TEI -> pdf, django, epub) (TODO)

TODO (status: scripts broken)
1 change: 1 addition & 0 deletions docker-compose.yaml
Expand Up @@ -15,6 +15,7 @@ services:
environment:
- INPUT_DIR=${INPUT_DIR_IN_CONTAINER}
- OUTPUT_DIR=${OUTPUT_DIR_IN_CONTAINER}
- DEPENDENCIES_DIR=${DEPENDENCIES_DIR_IN_CONTAINER}
- INSTALL_DIR=${SRC_DIR_IN_CONTAINER}
ports: []
user: ${USER}:${GROUP}
5 changes: 5 additions & 0 deletions scripts/config/env.conf
Expand Up @@ -14,11 +14,16 @@ CONTAINER_NAME=eoa_skripts

SRC_DIR=src
SRC_DIR_IN_CONTAINER=/eoa/skripts

INPUT_DIR=input
INPUT_DIR_IN_CONTAINER=/eoa/input

OUTPUT_DIR=output
OUTPUT_DIR_IN_CONTAINER=/eoa/output

DEPENDENCIES_DIR=dependencies
DEPENDENCIES_DIR_IN_CONTAINER=/eoa/dependencies

###################################################
# user and group:
# USER=$(id -u)
Expand Down
22 changes: 10 additions & 12 deletions scripts/exit.py
Expand Up @@ -6,22 +6,13 @@
import shutil
import os

def rm_dirs( config ):
path = Path( BASE_DIR, config['INPUT_DIR'] )
def rm_dirs( config, rm_deps):
path = Path( BASE_DIR, config['DEPENDENCIES_DIR'] )
print( "removing dir '{}'".format( path ) )
shutil.rmtree(
path,
ignore_errors=True
)
# os.system('rm -rf "{}"'.format( path ))

path = Path( BASE_DIR, config['OUTPUT_DIR'] )
print( "removing dir '{}'".format( path ) )
shutil.rmtree(
path,
ignore_errors=True
)
# os.system('rm -rf "{}"'.format( path ))

def rm_docker_env_file( config ):
path = Path(
Expand All @@ -39,6 +30,10 @@ def rm_docker_env_file( config ):
parser = ArgumentParser(
description="clean up the repository"
)
parser.add_argument(
"--rm-deps",
action = "store_true"
)
parser.add_argument(
"--env-file",
action = "store_true"
Expand All @@ -53,6 +48,9 @@ def rm_docker_env_file( config ):

stop( config )

rm_dirs( config )
rm_dirs(
config,
rm_deps = args.rm_deps or args.all
)
if args.env_file or args.all:
rm_docker_env_file( config )
62 changes: 40 additions & 22 deletions scripts/init.py
Expand Up @@ -2,6 +2,7 @@

from utils.settings import BASE_DIR, load_config, create_docker_env_file
from utils.functions import exec_in_container, run
from stop import stop

from pathlib import Path
import shlex
Expand All @@ -12,11 +13,8 @@
from time import sleep

BASE_DIR = Path( __file__ ).parent.parent
DEP_DIR = BASE_DIR / "dependencies"


SQLDB_WAIT_TIME=20

def create_dir(dir):
print( "creating dir '{}'".format( dir ) )
Path(dir).mkdir(
Expand All @@ -36,6 +34,9 @@ def copy_dir(src, dst):
)

def create_dirs( config ):
create_dir(
BASE_DIR / config['DEPENDENCIES_DIR']
)
create_dir(
BASE_DIR / config['INPUT_DIR']
)
Expand All @@ -47,23 +48,26 @@ def install_git_dep(
repo_name,
repo_uri,
repo_hash,
init_script = None
force = False,
init_script = None,
):
if (DEP_DIR / repo_name).exists():
shutil.rmtree( DEP_DIR / repo_name )
DEP_DIR = BASE_DIR / config['DEPENDENCIES_DIR']
if not((DEP_DIR / repo_name).exists()) or force:
if (DEP_DIR / repo_name).exists():
shutil.rmtree( DEP_DIR / repo_name )

subprocess.check_call(
["git", "clone", repo_uri, DEP_DIR / repo_name]
)
subprocess.check_call(
["git", "checkout", repo_hash],
cwd = DEP_DIR / repo_name
)
if init_script is not None:
subprocess.check_call(
shlex.split( init_script ),
["git", "clone", repo_uri, DEP_DIR / repo_name]
)
subprocess.check_call(
["git", "checkout", repo_hash],
cwd = DEP_DIR / repo_name
)
if init_script is not None:
subprocess.check_call(
shlex.split( init_script ),
cwd = DEP_DIR / repo_name
)

if __name__ == '__main__':

Expand All @@ -72,6 +76,10 @@ def install_git_dep(
parser = ArgumentParser(
description="initialize the repository: download git deps, create directories, etc"
)
parser.add_argument(
"--force-deps",
action = "store_true"
)
parser.add_argument(
"--build",
action = "store_true"
Expand All @@ -84,20 +92,30 @@ def install_git_dep(
# load env_file:
config = load_config()

create_dirs( config )

## install git dependencies:
'''
install_git_dep(
repo_name = "eoa-publication-model",
repo_uri = "https://github.molgen.mpg.de/EditionOpenAccess/eoa-publication-model.git",
repo_hash = "d76a81feef1ebb708a90376d3f5a7eccb51807b0"
repo_name = "TEI",
repo_uri = "https://github.com/TEIC/TEI.git",
repo_hash = "7fbbc7c5c2ba533dc70f561b27101dbfa7f519a0",
force = args.force_deps,
)
install_git_dep(
repo_name = "Stylesheets",
repo_uri = "https://github.com/TEIC/stylesheets.git",
repo_hash = "2a01be46ee82fce5eba6074359b3d18db2222e0c",
force = args.force_deps,
)
'''

create_dirs( config )

# rebuild docker image:
if args.build:
run(
env = config,
build = True,
)
stop(
env = config,
)

print( "done." )
10 changes: 5 additions & 5 deletions src/data/aux/formula.tex
Expand Up @@ -14,8 +14,8 @@

% Definition der Schriftarten für die einzelnen Schriftsysteme.
% Das Paket zhspacing fügt weitere Unterstützung für Chinesisch hinzu
\newfontfamily\zhfont{BiauKai}
\newfontfamily\zhpunctfont{BiauKai}
\newfontfamily\zhfont{Noto Serif CJK SC}
\newfontfamily\zhpunctfont{Noto Serif CJK SC}
\usepackage{zhspacing}
\zhspacing

Expand All @@ -27,8 +27,8 @@
\XeTeXcharclass`’=6
\XeTeXcharclass`…=6

\newfontfamily\textchinese{BiauKai}
\newfontfamily\chinesefont{BiauKai}
\newfontfamily\textchinese{Noto Serif CJK SC}
\newfontfamily\chinesefont{Noto Serif CJK SC}
\newfontfamily\germanfont{Times New Roman}
\newfontfamily\englishfont{Times New Roman}
\newfontfamily\greekfont{Times New Roman}
Expand All @@ -55,4 +55,4 @@

$DERINHALT
\end{document}
\end{document}

0 comments on commit 381b325

Please sign in to comment.