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 --- diff --git a/cmigrate.py b/cmigrate.py index e1ec253..cff0057 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'] + '/bin/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(): @@ -71,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) @@ -111,3 +112,4 @@ def build_dockerfile(runtime): if __name__ == '__main__': build_dockerfile() + 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