Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'dockerize'
  • Loading branch information
EsGeh authored and EsGeh committed Nov 26, 2019
2 parents d6a21f5 + 09b509a commit 8400697
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 33 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -55,11 +55,11 @@ Docker images are not deleted though.

# General Usage Information

The `input` directory is for unprocessed publications as you might have received them from authors or editors.
The `output` directory is for processed publications and intermediate data.
The `runtime/input` directory is for unprocessed publications as you might have received them from authors or editors.
The `runtime/output` directory is for processed publications and intermediate data.
When entering the docker container conversion scripts are in your $PATH, and can executed like any other executable.
In your `HOME` directory you'll find `input` and `output` directories, which are docker volumes mirroring the directories of the same name outside of the container.
In order to compile a publication, just copy them into `./input`, enter the docker container, and call the necessary scripts.
In your `HOME` directory you'll find `input` and `output` directories, which are docker volumes mirroring the directories in `runtime/` outside of the container.
In order to compile a publication, just copy them into `runtime/input`, enter the docker container, and call the necessary scripts.
For an example, see chapter "Workflows".

## Configuration
Expand All @@ -83,8 +83,8 @@ Compiling your documents involves following a workflow which can consist of seve

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

The following description uses the example publication in `input/example` (from the `eoa-publication-model` repository).
In order to apply the workflow to any other publication copy it into the `input/` directory and adjust paths in the description accordingly.
The following description uses the example publication in `runtime/input/example` (copied from the `eoa-publication-model` repository).
In order to apply the workflow to any other publication copy it into the `runtime/input/` directory and adjust paths in the description accordingly.

1. enter the docker container

Expand Down
8 changes: 5 additions & 3 deletions scripts/config/env.conf → scripts/config/env_default.conf
Expand Up @@ -18,13 +18,15 @@ SRC_DIR_IN_CONTAINER=/eoa/skripts
DEPENDENCIES_DIR=dependencies
DEPENDENCIES_DIR_IN_CONTAINER=/eoa/dependencies

HOME_DIR=runtime/work_dir
RUNTIME_DIR=runtime

HOME_DIR=${RUNTIME_DIR}/work_dir
HOME_DIR_IN_CONTAINER=/home/work_dir

INPUT_DIR=runtime/input
INPUT_DIR=${RUNTIME_DIR}/input
INPUT_DIR_IN_CONTAINER=/eoa/input

OUTPUT_DIR=runtime/output
OUTPUT_DIR=${RUNTIME_DIR}/output
OUTPUT_DIR_IN_CONTAINER=/eoa/output

###################################################
Expand Down
57 changes: 37 additions & 20 deletions scripts/exit.py
@@ -1,56 +1,73 @@
#!/usr/bin/env python3

from utils.settings import BASE_DIR, load_config
from utils.settings import env_file, BASE_DIR, load_config, create_docker_env_file

from pathlib import Path
import shutil
import os

def rm_dirs( config, rm_deps):
path = Path( BASE_DIR, config['DEPENDENCIES_DIR'] )
def rm_dir(
path
):
print( "removing dir '{}'".format( path ) )
shutil.rmtree(
path,
ignore_errors=True
)

def rm_docker_env_file( config ):
path = Path(
BASE_DIR / ".env"
)
print( "removing '{}'".format( path ) )
path.unlink()
def rm_file(
path
):
if path.is_file():
print( "removing file '{}'".format( path ) )
path.unlink()

if __name__ == '__main__':

from argparse import ArgumentParser

if not env_file.exists():
create_docker_env_file()
config = load_config()

parser = ArgumentParser(
description="clean up the repository"
)
parser.add_argument(
"--rm-deps",
action = "store_true"
"-d", "--deps",
action = "store_true",
help = "remove dependencies",
)
parser.add_argument(
"-r", "--runtime",
action = "store_true",
help = "remove '{rt_dir}'".format( rt_dir = BASE_DIR / config['RUNTIME_DIR'] ),
)
parser.add_argument(
"--env-file",
action = "store_true"
"-e", "--env",
action = "store_true",
help = "remove existing .env file",
)
parser.add_argument(
"--all",
action = "store_true"
action = "store_true",
help = "purge in every way",
)
args = parser.parse_args()

from stop import stop

stop( config )

rm_dirs(
config,
rm_deps = args.rm_deps or args.all
)
if args.env_file or args.all:
rm_docker_env_file( config )
if args.deps or args.all:
rm_dir(
path = BASE_DIR / config['DEPENDENCIES_DIR']
)
if args.runtime or args.all:
rm_dir(
path = BASE_DIR / config['RUNTIME_DIR']
)
if args.env or args.all:
rm_file(
env_file
)
13 changes: 10 additions & 3 deletions scripts/init.py
Expand Up @@ -94,12 +94,19 @@ def install_git_dep(
description="initialize the repository: download git deps, create directories, etc"
)
parser.add_argument(
"--force-deps",
action = "store_true"
"-d", "--force-deps",
action = "store_true",
help = "download dependencies, even if yet existing",
)
parser.add_argument(
"--build",
action = "store_true"
action = "store_true",
help = "rebuild docker image from Dockerfile",
)
parser.add_argument(
"-e", "--env",
action = "store_true",
help = "overwrite existing .env file",
)
args = parser.parse_args()

Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/settings.py
Expand Up @@ -8,7 +8,7 @@
BASE_DIR = Path( __file__ ).parent.parent.parent
SCRIPT_DIR = Path( __file__ ).parent.parent

orig_config_file = SCRIPT_DIR / "config" / "env.conf"
orig_config_file = SCRIPT_DIR / "config" / "env_default.conf"
env_file = BASE_DIR / ".env"


Expand Down

0 comments on commit 8400697

Please sign in to comment.