Fix the relative path problem when running quay from non-root

This commit is contained in:
Jake Moshenko 2017-07-13 15:30:50 -04:00
parent ee67674e5b
commit 3b79955c8c
3 changed files with 12 additions and 9 deletions

View file

@ -18,6 +18,7 @@ from buildman.jobutil.workererror import WorkerError
from data import model
from data.database import BUILD_PHASE
from data.model import InvalidRepositoryBuildException
from util import slash_join
HEARTBEAT_DELTA = datetime.timedelta(seconds=60)
BUILD_HEARTBEAT_DELAY = datetime.timedelta(seconds=30)
@ -180,9 +181,10 @@ class BuildComponent(BaseComponent):
context = build_config.get('context', '')
if not (dockerfile_path == '' or context == ''):
# This should not happen and can be removed when we centralize validating build_config
if ".." in os.path.relpath(dockerfile_path, context):
dockerfile_abspath = slash_join('', dockerfile_path)
if ".." in os.path.relpath(dockerfile_abspath, context):
return os.path.split(dockerfile_path)
dockerfile_path = os.path.relpath(dockerfile_path, context)
dockerfile_path = os.path.relpath(dockerfile_abspath, context)
return context, dockerfile_path