Skip to Content
Technical Articles

Eclipse Dirigible – Building a Docker Image for Your Application

Overview


Eclipse Dirigible is an open-source cloud development platform that provides capabilities for end-to-end development processes from database modeling and management, through RESTful services using server-side JavaScript, to pattern-based user interface generation, role-based security, external services integration, testing, debugging, operations and monitoring.

Some of the unique features include:

The platform aims to unify open-source business services by providing software developers with a convenient set of tools for building, running, and operating business applications in the Cloud. Dirigible is also part of the Eclipse Cloud Development top-level project.

Setup


Starting with Eclipse Dirigible 5.0, there are built-in integrations with the SAP Cloud Platform Cloud Foundry and Kyma environments. To deploy Eclipse Dirigible on either one of these environments, you need to use a Docker image. The Docker image usually includes both the Web IDE and the Runtime modules of Dirigible – a setup which comes in handy during the development phase of your application. Once the development of your application is over and it’s time to move to the production phase, we recommend that you create a dedicated Docker image. Depending on the use case and the DevOps preferences, the Web IDE modules could be included or excluded from the build.

As a prerequisite, you should have Docker installed on your machine. To get started with Docker, visit the Get Docker page on the official website of Docker.

To make the Docker project setup easier, we are going to use the following dirigiblelabs/sample-docker-application sample GitHub repository:

  1. Clone the https://github.com/dirigiblelabs/sample-docker-application repository to your machine.
  2. Navigate to the repository folder.
  3. Execute the Docker build command:
    docker build -t hello-world-application -f Dockerfile .​
  4. Once the build finishes successfully, you can run locally the docker image using the following command:
    docker run --rm -p 8080:8080 hello-world-application​

Note that the 8080 port should not be used by another process. If there’s another process running on that port, stop that process and retry the run command.

Once the container starts successfully, you can navigate to http://localhost:8080 to access the “Hello World” application.

(Hello World Application)

 

Now let’s take a look at the folder structure of the sample repository.

(Repository Folder Structure)

Here, the Dockerfile and the helloWorld folder are the most important objects. In the Dockerfile, we can find the steps of the Docker build process. The helloWorld folder contains a Dirigible project/module which that we want to package into a separate Docker image and deploy it to production.

If we take a close look at the Dockerfile content, we can find the “parent” Dirigible image and the following build steps:

FROM dirigiblelabs/dirigible-runtime-anonymous:latest

RUN mkdir -p $CATALINA_HOME/target/dirigible/repository/root/registry/public/
COPY helloWorld/ $CATALINA_HOME/target/dirigible/repository/root/registry/public/helloWorld/

ENV DIRIGIBLE_HOME_URL=/services/v4/web/helloWorld/

So let’s take a look at each one of the lines:

  1. FROM dirigiblelabs/dirigible-runtime-anonymous:latest

    This is the “parent” image from which will initiate the Docker build. Depending on the use case, there are several images that you can be use here:

  2. RUN mkdir -p $CATALINA_HOME/target/dirigible/repository/root/registry/public/

    This command creates a specific Dirigible folder layout, where the application content will be placed afterwards. This step remains always the same.

  3. COPY helloWorld/ $CATALINA_HOME/target/dirigible/repository/root/registry/public/helloWorld/

    This command copies the helloWorld project/module into the specific Dirigible folder layout. If your application contains more than one project/module, then the same command should be applied multiple times for each and every project/module that you have. Note that the last path segment in the target location (“../registry/public/helloWorld/”) should match the name of the project/module (e.g. helloWorld). This requirement is almost always applicable, except for a few special cases.

  4. ENV DIRIGIBLE_HOME_URL=/services/v4/web/helloWorld/

    The last command sets the DIRIGIBLE_HOME_URL environment variable so that once the application root is accessed, it will be redirected to the specified location. You can find a list of all environment variables of Dirigible here. Note that this line is optional, because depending on the target platform (e.g. Cloud Foundry, Kyma, Kubernetes, etc.) there are different ways of providing the environment variables without setting them in the Docker image.

 

Here is another example of what a real Dockerfile, for the SAP Cloud Platform Cloud Foundry environment, should look like:

FROM dirigiblelabs/dirigible-sap-cf-runtime:5.5.0

RUN mkdir -p $CATALINA_HOME/target/dirigible/repository/root/registry/public/
COPY myModule1/ $CATALINA_HOME/target/dirigible/repository/root/registry/public/myModule1/
COPY myModule2/ $CATALINA_HOME/target/dirigible/repository/root/registry/public/myModule2/
COPY myModule3/ $CATALINA_HOME/target/dirigible/repository/root/registry/public/myModule3/

ENV DIRIGIBLE_HOME_URL=/services/v4/web/myModule1/

And another one for the SAP Cloud Platform Kyma environment:

FROM dirigiblelabs/dirigible-sap-kyma-runtime:5.5.0

RUN mkdir -p $CATALINA_HOME/target/dirigible/repository/root/registry/public/
COPY myModule1/ $CATALINA_HOME/target/dirigible/repository/root/registry/public/myModule1/
COPY myModule2/ $CATALINA_HOME/target/dirigible/repository/root/registry/public/myModule2/
COPY myModule3/ $CATALINA_HOME/target/dirigible/repository/root/registry/public/myModule3/

ENV DIRIGIBLE_HOME_URL=/services/v4/web/myModule1/

 

After the Dockerfile is created according to your application and your use case, and the Dirigible project(s)/module(s) are placed in the same directory, it’s time to build and push the Docker image to either public or private Docker registry.

To build your application image, use the following command:

docker build -t <my-application-name> -f Dockerfile .​

Then, push the Docker image to a Docker repository using these commands:

docker tag hello-world-application <your-docker-organization>/<my-application-name>

docker push <your-docker-organization>/<my-application-name>

 

To push a Docker image to a registry, use the docker tag and docker push commands in the following format:

 

docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]

docker push NAME[:TAG]

Here is an example:

docker tag 518a41981a6a myRegistry.com/myImage

docker push myRegistry.com/myImage

For more information on “How to push a docker image to a private repository” visit this StackOverflow post.

Notes


Next, you can visit the Samples section to master some of the basic Eclipse Dirigible functionalities, explore the Enterprise JavaScript APIs, check out the YouTube channel for video content, or simply visit the official site for news and updates.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.