mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/file-setup.git
synced 2024-12-27 11:54:19 +00:00
30 lines
888 B
Plaintext
30 lines
888 B
Plaintext
|
#!/usr/bin/env python3
|
||
|
# coding=utf-8
|
||
|
|
||
|
from argparse import ArgumentParser
|
||
|
import os
|
||
|
import subprocess
|
||
|
|
||
|
CONTAINER_IMAGE = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/file_setup:latest'
|
||
|
CONTAINER_INPUT_DIR = '/input'
|
||
|
CONTAINER_OUTPUT_DIR = '/output'
|
||
|
UID = str(os.getuid())
|
||
|
GID = str(os.getgid())
|
||
|
|
||
|
parser = ArgumentParser(add_help=False)
|
||
|
parser.add_argument('-i')
|
||
|
parser.add_argument('-o')
|
||
|
args, remaining_args = parser.parse_known_args()
|
||
|
|
||
|
cmd = ['docker', 'run', '--rm', '-it', '-u', '{}:{}'.format(UID, GID)]
|
||
|
if args.o is not None:
|
||
|
cmd += ['-v', '{}:{}'.format(os.path.abspath(args.o), CONTAINER_OUTPUT_DIR)]
|
||
|
remaining_args.insert(0, CONTAINER_OUTPUT_DIR)
|
||
|
if args.i is not None:
|
||
|
cmd += ['-v', '{}:{}'.format(os.path.abspath(args.i), CONTAINER_INPUT_DIR)]
|
||
|
remaining_args.insert(0, CONTAINER_INPUT_DIR)
|
||
|
cmd.append(CONTAINER_IMAGE)
|
||
|
cmd += remaining_args
|
||
|
|
||
|
subprocess.run(cmd)
|