Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

Expand Down
32 changes: 17 additions & 15 deletions cmigrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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)
Expand Down Expand Up @@ -111,3 +112,4 @@ def build_dockerfile(runtime):

if __name__ == '__main__':
build_dockerfile()

10 changes: 6 additions & 4 deletions templates/Dockerfile-jboss.j2
Original file line number Diff line number Diff line change
@@ -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"]
COPY {{ artefacts.APP_CONFIG }} $JBOSS_HOME/standalone/configuration/standalone.xml
EXPOSE 8080 9990 9999
RUN chown jboss:jboss $JBOSS_HOME/standalone/deployments/
USER jboss