🚧 Add a wrapper script to call containers
parent
b6bbc7ca3a
commit
688db6ac64
@ -1,3 +1,4 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*.egg-info/
|
||||
|
@ -0,0 +1 @@
|
||||
__import__("pkg_resources").declare_namespace(__name__)
|
@ -0,0 +1 @@
|
||||
from .cli import *
|
@ -0,0 +1,42 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
DOCKER_IMAGE_PREFIX = os.environ.get("DOCKER_IMAGE_PREFIX", "my_ocrd_workflow")
|
||||
DOCKER_IMAGE_TAG = os.environ.get("DOCKER_IMAGE_TAG", "latest")
|
||||
LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO")
|
||||
|
||||
|
||||
def main():
|
||||
argv = sys.argv.copy()
|
||||
argv[0] = os.path.basename(argv[0])
|
||||
|
||||
if argv[0] == "ocrd":
|
||||
docker_image = "%s-core:%s" % (DOCKER_IMAGE_PREFIX, DOCKER_IMAGE_TAG)
|
||||
|
||||
docker_run(argv, docker_image)
|
||||
|
||||
|
||||
def docker_run(argv, docker_image):
|
||||
docker_run_options = []
|
||||
docker_run_options.extend(["--rm", "-t"])
|
||||
docker_run_options.extend(["--mount", "type=bind,src=%s,target=/data" % os.getcwd()])
|
||||
docker_run_options.extend(["--user", "%s:%s" % (os.getuid(), os.getgid())])
|
||||
docker_run_options.extend(["-e", "LOG_LEVEL=%s" % LOG_LEVEL])
|
||||
|
||||
# The containers currently need to run privileged to allow it to read from e.g.
|
||||
# /home on SELinux secured systems such as Fedora. We might want to use udica
|
||||
# instead in the future.
|
||||
docker_run_options.extend(["--privileged=true"])
|
||||
|
||||
docker_run_options.extend([docker_image])
|
||||
docker_run_options.extend(argv)
|
||||
|
||||
docker_run_command = ["docker", "run"] + docker_run_options
|
||||
c = subprocess.run(docker_run_command)
|
||||
sys.exit(c.returncode)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,18 @@
|
||||
from io import open
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
setup(
|
||||
name="ocrd-galley",
|
||||
author="Mike Gerber, The QURATOR SPK Team",
|
||||
author_email="mike.gerber@sbb.spk-berlin.de, qurator@sbb.spk-berlin.de",
|
||||
description="A Dockerized test environment for OCR-D processors ship",
|
||||
keywords="qurator ocr ocr-d",
|
||||
license="Apache",
|
||||
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
|
||||
namespace_packages=["qurator"],
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
"ocrd=qurator.ocrd_galley.cli:main",
|
||||
]
|
||||
},
|
||||
)
|
Loading…
Reference in New Issue