Skip to content

Commit

Permalink
Improve test, if we're running in docker (#10531)
Browse files Browse the repository at this point in the history
  • Loading branch information
p0psicles authored Apr 24, 2022
1 parent 45e697d commit 445d1e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion medusa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def initialize(self, console_logging=True):
app.BRANCH = commit_branch_env

# Asume we only have these environ variables when building a docker container.
app.RUNS_IN_DOCKER = os.environ.get('MEDUSA_COMMIT_HASH') and os.environ.get('MEDUSA_COMMIT_BRANCH')
app.RUNS_IN_DOCKER = CheckVersion.runs_in_docker()

app.ACTUAL_CACHE_DIR = check_setting_str(app.CFG, 'General', 'cache_dir', 'cache')

Expand Down
15 changes: 14 additions & 1 deletion medusa/updater/version_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,17 @@ def runs_in_docker():
if app.RUNS_IN_DOCKER is not None:
return app.RUNS_IN_DOCKER

return os.environ.get('MEDUSA_COMMIT_HASH') and os.environ.get('MEDUSA_COMMIT_BRANCH')
try:
path = '/.dockerenv'
if os.path.isfile(path):
app.RUNS_IN_DOCKER = True
return True
except (EnvironmentError, OSError) as error:
log.info(u'Tried to check the path {path} if we are running in a docker container, '
u'but an error occurred: {error}', {'path': path, 'error': error})

if os.environ.get('MEDUSA_COMMIT_HASH') and os.environ.get('MEDUSA_COMMIT_BRANCH'):
app.RUNS_IN_DOCKER = True
return True

return False

0 comments on commit 445d1e5

Please sign in to comment.