diff --git a/container/__init__.py b/container/__init__.py index 706185e3..c57d236c 100644 --- a/container/__init__.py +++ b/container/__init__.py @@ -4,11 +4,27 @@ __version__ = '0.9.3rc0' import os +import sys import functools # Many features of Ansible Container are flagged on whether or not we're running # inside the Conductor container or not. This is the flag. ENV = 'conductor' if os.environ.get('ANSIBLE_CONTAINER') else 'host' +REMOTE_DEBUGGING = True if os.environ.get('REMOTE_DEBUGGING') else False + +if ENV != 'host' and REMOTE_DEBUGGING: + print("Checking for debugging capabilities...") + try: + sys.path.append('/_ansible/build/pycharm-debug.egg') + print("import pydevd && set trace 172.17.0.1 55507") + import pydevd + # 172.17.0.1 host.docker.internal + pydevd.settrace('172.17.0.1', port=55507, stdoutToServer=True, stderrToServer=True) + except ImportError: + pass + except Exception: + pass + def conductor_only(fn): @functools.wraps(fn) diff --git a/container/docker/engine.py b/container/docker/engine.py index 0e632faa..36ddc81d 100644 --- a/container/docker/engine.py +++ b/container/docker/engine.py @@ -1082,6 +1082,11 @@ def build_conductor_image(self, base_path, base_image, prebaking=False, cache=Tr req_yml_dir = (package_dir if os.path.exists(os.path.join(package_dir, 'conductor-requirements.yml')) else FILES_PATH) + for filename in ['pycharm-debug.egg']: + file_path = os.path.join(setup_py_dir, filename) + if os.path.exists(file_path): + tarball.add(file_path, + arcname=os.path.join('build-src', filename)) tarball.add(os.path.join(setup_py_dir, 'setup.py'), arcname='container-src/conductor-build/setup.py') tarball.add(os.path.join(req_txt_dir, 'conductor-requirements.txt'), diff --git a/container/docker/templates/conductor-local-dockerfile.j2 b/container/docker/templates/conductor-local-dockerfile.j2 index 93ff2000..f0a94fa6 100644 --- a/container/docker/templates/conductor-local-dockerfile.j2 +++ b/container/docker/templates/conductor-local-dockerfile.j2 @@ -2,6 +2,7 @@ FROM {{ conductor_base }} {% set distro = original_base.split(':')[0] %} # The COPY here will break cache if the requirements or ansible.cfg has changed COPY /build-src /_ansible/build +COPY /container-src /_ansible/container {% if install_requirements %} RUN {{ install_requirements }}