Skip to main content

Deploying M.App Enterprise with Docker

POSTED: | UPDATED: | by Marina Lanxinger

This article explores the integration of Docker with M.App Enterprise, highlighting the benefits of containerization for efficient deployment, scalability, and management.
⚠️
Docker support for M.App Enterprise and Fusion is currently available only for Windows environments.

What is Docker?

Docker has emerged as a leading platform for developing, shipping, and running applications. Docker utilizes containerization technology to package software into standardized units called containers. These containers encapsulate all the necessary components, including the code, runtime, libraries, and system tools, ensuring that applications run consistently across different computing environments.

Advantages of Containers

Containers offer several advantages over traditional virtual machines. They are lightweight, as they share the host operating system's kernel, which results in faster startup times and lower resource consumption. This efficiency makes containers ideal for deploying and scaling applications in various environments, from local development machines to large-scale cloud infrastructure.

Scalability: Containers can be easily scaled up or down to meet varying demand, ensuring optimal performance and resource utilization.
Portability: Containers can run consistently across different environments, from local development setups to cloud-based production systems, reducing the "it works on my machine" problem.
Easy Management: Docker simplifies the management of application dependencies and configurations, making it easier to update and maintain M.App Enterprise services.
Consistency: By providing a consistent runtime environment, Docker ensures that applications behave the same way in development, testing, and production, reducing bugs and deployment issues.

In the following sections, we will delve into how Docker can be integrated with M.App Enterprise to enhance its deployment and management.

Preliminaries

Make sure Docker is installed on your system. Find further instructions on the official Docker Website https://www.docker.com/products/docker-desktop/

Ensure Docker Compose is installed as well. It usually comes bundled with Docker Desktop.

Create Dockerfiles

A Dockerfile is a text document that contains all the commands to assemble an image. You will need to create Dockerfiles for each of your M.App Enterprise components.These Dockerfiles will define the environment and dependencies for each service.

Just open a Text Editor, create a new file and save it as Dockerfile.mapp in your desired directory. Add the following content into Dockerfile.mapp and fill out the placeholders:

# Dockerfile.mapp

# Use a base image with necessary dependencies
FROM openjdk:11-jre-slim

# Set environment variables with placeholders
ENV MAE_CONNECTIONSTRING="PORT=5432;HOST=<DB_HOST>;USER ID=<DB_USER>;PASSWORD=<DB_PASSWORD>;DATABASE=<DB_NAME>"
ENV MAE_PROVIDERTYPE="PostgreSql"
ENV MAE_WAREHOUSELOCATION="\\<WAREHOUSE_HOST>\\<WAREHOUSE_PATH>"
ENV MAE_WAREHOUSEUSER="<WAREHOUSE_USER>"
ENV MAE_WAREHOUSEPASSWORD="<WAREHOUSE_PASSWORD>"
ENV MAE_ADMINUSER="<ADMIN_USER>"
ENV MAE_ADMINPASSWORD="<ADMIN_PASSWORD>"

# Expose the port the service runs on
EXPOSE 8080

# Command to run the service
CMD ["java", "-jar", "/path/to/mapp-service.jar"]
  

Create another file Dockerfile.fusion and add the following content

# Dockerfile.fusion

# Use a base image with necessary dependencies
FROM openjdk:11-jre-slim

# Set environment variables with placeholders
ENV MAE_AUTHSERVICEURL="http://<AUTH_SERVICE_HOST>:<AUTH_SERVICE_PORT>/api/v1/oauth2"
ENV MAE_WAREHOUSELOCATION="\\<WAREHOUSE_HOST>\\<WAREHOUSE_PATH>"
ENV MAE_WAREHOUSEUSER="<WAREHOUSE_USER>"
ENV MAE_WAREHOUSEPASSWORD="<WAREHOUSE_PASSWORD>"
ENV MAE_CONNECTIONSTRING="jdbc:postgresql://<DB_HOST>:5432/<DB_NAME>"
ENV MAE_DBUSER="<DB_USER>"
ENV MAE_DBPASSWORD="<DB_PASSWORD>"
ENV MAE_LICENSESERVER="<LICENSE_SERVER_HOST>:<LICENSE_SERVER_PORT>"

# Expose the port the service runs on
EXPOSE 8081

# Command to run the service
CMD ["java", "-jar", "/path/to/fusion-service.jar"]
  

Create Docker Compose File

Create a file named docker-compose.yml in the same directory as your previous files.

version: '3.8'

services:
  mapp_service:
    build:
      context: .
      dockerfile: Dockerfile.mapp
    environment:
      MAE_CONNECTIONSTRING: "PORT=5432;HOST=<DB_HOST>;USER ID=<DB_USER>;PASSWORD=<DB_PASSWORD>;DATABASE=<DB_NAME>"
      MAE_PROVIDERTYPE: "PostgreSql"
      MAE_WAREHOUSELOCATION: "\\<WAREHOUSE_HOST>\\<WAREHOUSE_PATH>"
      MAE_WAREHOUSEUSER: "<WAREHOUSE_USER>"
      MAE_WAREHOUSEPASSWORD: "<WAREHOUSE_PASSWORD>"
      MAE_ADMINUSER: "<ADMIN_USER>"
      MAE_ADMINPASSWORD: "<ADMIN_PASSWORD>"
    ports:
      - "8080:8080"

  fusion_service:
    build:
      context: .
      dockerfile: Dockerfile.fusion
    environment:
      MAE_AUTHSERVICEURL: "http://<AUTH_SERVICE_HOST>:<AUTH_SERVICE_PORT>/api/v1/oauth2"
      MAE_WAREHOUSELOCATION: "\\<WAREHOUSE_HOST>\\<WAREHOUSE_PATH>"
      MAE_WAREHOUSEUSER: "<WAREHOUSE_USER>"
      MAE_WAREHOUSEPASSWORD: "<WAREHOUSE_PASSWORD>"
      MAE_CONNECTIONSTRING: "jdbc:postgresql://<DB_HOST>:5432/<DB_NAME>"
      MAE_DBUSER: "<DB_USER>"
      MAE_DBPASSWORD: "<DB_PASSWORD>"
      MAE_LICENSESERVER: "<LICENSE_SERVER_HOST>:<LICENSE_SERVER_PORT>"
    ports:
      - "8081:8081"
  

Build and Run the Containers

This step involves using the Docker CLI to build the Docker images and run the containers using Docker Compose.

Open your preferred command line interface and navigate to the directory where your Dockerfiles are located.

Build the Docker Images

Use Docker Compose to build the Docker images defined in your docker-compose.yml file. This command will read the docker-compose.yml file and build the images specified in the build sections of the services.

docker-compose build
  

This command will:

  • Read the Dockerfile.mapp and Dockerfile.fusion
  • Download the necessary base images
  • Install any dependencies and set up the environment as defined in the Dockerfiles
  • Create Docker images for mapp_service and fusion_service

Run the Containers

After successfully building the images, you can use Docker Compose to run the containers.

docker-compose up
    

To run them in detached mode use the command below.

docker-compose up -d
  

This command will:

  • Create and start the containers for mapp_service and fusion_service
  • Map the specified ports from the containers to your host machine (e.g., 8080:8080 for mapp_service and 8081:8081 for fusion_service)
  • Stream the logs from the running containers to your terminal

Before you access the services, verify the containers are running.

docker-compose ps
  

Access the Services

You can access the services running in the containers using your web browser or any HTTP client. Open your browser and navigate to:

http://localhost:8080 for the mapp_service
http://localhost:8081 for the fusion_service

💡
Replace localhost with the appropriate host if you are running Docker on a remote machine.

To stop the containers simply use the command below.


docker-compose down