From 91110ca879faf9b7ee0d8135709caaafa26399bf Mon Sep 17 00:00:00 2001 From: Joby Chacko Date: Sun, 20 Nov 2022 14:33:02 +0530 Subject: [PATCH 1/5] Update cmigrate.py --- cmigrate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmigrate.py b/cmigrate.py index e1ec253..b2032fa 100644 --- a/cmigrate.py +++ b/cmigrate.py @@ -42,9 +42,9 @@ def get_artefacts(app_runtime): if "jboss" in str(proc.as_dict().values()): break artefact['APP_RUNTIME'] = app_runtime - war_files = glob(proc.environ()['JBOSS_HOME'] + 'standalone/deployments/*.war') + war_files = glob(proc.environ()['JBOSS_HOME'] + '/standalone/deployments/*.war') artefact['APP_DIR'] = war_files - artefact['APP_CONFIG'] = proc.environ()['JBOSS_HOME'] + '/bin/standalone/configuration/standalone.xml' + artefact['APP_CONFIG'] = proc.environ()['JBOSS_HOME'] + '/standalone/configuration/standalone.xml' for conn in proc.connections(): if conn.laddr.port == 8080: continue From 2148e8d160ab69a2637ca0c5dd4065a15fe253a2 Mon Sep 17 00:00:00 2001 From: Joby Chacko Date: Sun, 20 Nov 2022 14:48:28 +0530 Subject: [PATCH 2/5] Update cmigrate.py --- cmigrate.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/cmigrate.py b/cmigrate.py index b2032fa..909dd67 100644 --- a/cmigrate.py +++ b/cmigrate.py @@ -36,20 +36,21 @@ def get_artefacts(app_runtime): continue else: artefact['APP_PORT'] = conn.laddr.port - # jboss - if app_runtime=='jboss': - for proc in psutil.process_iter(): - if "jboss" in str(proc.as_dict().values()): - break - artefact['APP_RUNTIME'] = app_runtime - war_files = glob(proc.environ()['JBOSS_HOME'] + '/standalone/deployments/*.war') - artefact['APP_DIR'] = war_files - artefact['APP_CONFIG'] = proc.environ()['JBOSS_HOME'] + '/standalone/configuration/standalone.xml' - for conn in proc.connections(): - if conn.laddr.port == 8080: - continue - else: - artefact['APP_PORT'] = conn.laddr.port + + if app_runtime=='jboss': + for proc in psutil.process_iter(): + if "jboss" in str(proc.as_dict().values()): + break + artefact['APP_RUNTIME'] = app_runtime + war_files = glob(proc.environ()['JBOSS_HOME'] + '/standalone/deployments/*.war') + artefact['APP_DIR'] = war_files + artefact['APP_CONFIG'] = proc.environ()['JBOSS_HOME'] + '/standalone/configuration/standalone.xml' + for conn in proc.connections(): + if conn.laddr.port == 8080: + continue + else: + artefact['APP_PORT'] = conn.laddr.port + if app_runtime == 'httpd': for proc in psutil.process_iter(): @@ -111,3 +112,4 @@ def build_dockerfile(runtime): if __name__ == '__main__': build_dockerfile() + From 053fba7279fd629b2a95eb6ac368815d0fd62d20 Mon Sep 17 00:00:00 2001 From: Joby Chacko Date: Tue, 22 Nov 2022 09:01:42 +0530 Subject: [PATCH 3/5] Update Dockerfile-jboss.j2 --- templates/Dockerfile-jboss.j2 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/Dockerfile-jboss.j2 b/templates/Dockerfile-jboss.j2 index 759732d..0666407 100644 --- a/templates/Dockerfile-jboss.j2 +++ b/templates/Dockerfile-jboss.j2 @@ -1,8 +1,10 @@ FROM registry.access.redhat.com/jboss-eap-7/eap71-openshift LABEL maintainer="xmigrate.cloud" {% for artefact in artefacts.APP_DIR %} -COPY {{ artefact }} standalone/deployments +COPY {{ artefact }} $JBOSS_HOME/standalone/deployments/ +USER root {% endfor %} -COPY {{ artefacts.APP_CONFIG }} /bin/standalone/configuration/standalone.xml -EXPOSE {{ artefacts.APP_PORT }} -CMD ["standalone.sh", "run"] \ No newline at end of file +COPY {{ artefacts.APP_CONFIG }} $JBOSS_HOME/standalone/configuration/standalone.xml +EXPOSE 8080 9990 9999 +RUN chown jboss:jboss $JBOSS_HOME/standalone/deployments/ +USER jboss From 002fa6a91bdbc83fe2ed20102b6ac5b821d77570 Mon Sep 17 00:00:00 2001 From: Joby Chacko Date: Tue, 22 Nov 2022 09:02:23 +0530 Subject: [PATCH 4/5] Update cmigrate.py --- cmigrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmigrate.py b/cmigrate.py index 909dd67..cff0057 100644 --- a/cmigrate.py +++ b/cmigrate.py @@ -72,7 +72,7 @@ def generate_docker_file(artefacts): # elif artefacts['APP_RUNTIME'] == "httpd": # TEMPLATE_FILE = "Dockerfile-httpd.j2" template = templateEnv.get_template(TEMPLATE_FILE) - output_dir = './artefact' + output_dir = 'artefact' isExist = os.path.exists(output_dir) if not isExist: os.makedirs(output_dir) From 225c53e9c2d59c50a13808f053ce334a7395cbd8 Mon Sep 17 00:00:00 2001 From: Joby Chacko Date: Tue, 22 Nov 2022 09:35:46 +0530 Subject: [PATCH 5/5] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3d8a0b0..00eebeb 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ # Overview Cmigrate is an open-source project for migrating your VM-based application deployments to container. Cmigrate is a CLI based tool wriitten in python which can discover the application runtime on the server and generate a docker file and the application artifacts to containerize. +![demo-tomcat-cmigrate](https://user-images.githubusercontent.com/67468756/203218711-80d74f32-874c-433b-aa35-2675dc97aeaf.gif) + + ## Current release ---