Dockerizing Mule Application
This article contains the step by step information on how to Dockerize MuleSoft Application. Read on for the tutorial!
Join the DZone community and get the full member experience.
Join For FreeDockerizing Mule Application
This article contains the step by step information on how to Dockerize MuleSoft Application. Here we will create a Docker image containing Mule Standalone server 3.9.4. As soon as our image is built, we will run the container to start the application.
As we can see in the Dockerfile, we have picked centos as our base image and installing the JDK 1.8, Maven, and Mule Standalone runtime on it. Once the environment setup is done then it's copying the application zip file into the apps folder of Mule_HOME.
Note: We have exposed port 8080 as our application port.
Step 1: Include the Dockerfile inside your application root directory.
x
FROM centos
ENV MULE_HOME /opt/mule
ENV MULE_VERSION 3.9.4
# yum install JDK,Maven and MuleStandalone runtime
RUN yum update -y \
&& yum install -y java-1.8.0-openjdk-devel maven zip \
&& yum clean all -y \
&& cd /opt \
&& curl -k -o mule-3.9.4.zip http://s3.amazonaws.com/new-mule-artifacts/mule-ee-distribution-standalone-3.9.4-hf1.zip \
&& unzip mule-3.9.4.zip \
&& mv mule-enterprise-standalone-$MULE_VERSION-hf1 mule
# Copy application files
COPY ./target/*.zip $MULE_HOME/apps/
# EXPOSED Application Port
EXPOSE 8080
ENTRYPOINT /opt/mule/bin/mule
Step 2: Build the Dockerfile to create an image, We are using "docker build" command for the same. Commands and Instructions given in the Dockerfile will be executed in order and for each instruction separate layer will be created since Docker follows the layered architecture.
Note: Run this command in your root application folder.
xxxxxxxxxx
docker build -t alawaniy/mule-dockerization .
Step 3 (Optional) : Once docker image is created we can push the image to Docker Hub Private Repository which can be shared across teams.
Note: You must have to login before pushing an image to Docker Hub.
xxxxxxxxxx
docker push alawaniy/mule-dockerization
Step 4: Run the image using the below command which will basically start the container but internally this will start the Mule Standalone server and your copied application will be deployed to the Server.
xxxxxxxxxx
docker run -it -p 8080:8080 alawaniy/mule-dockerization
Step 5: Test the Application by hitting the URL on the browser.
Note: My application is running on port 8080.
Hope this helps!
Thanks.
Keep learning.
Opinions expressed by DZone contributors are their own.
Comments