Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to reduce Red Hat Fuse image size

October 10, 2019
Pramod Padmanabhan
Related topics:
ContainersKubernetes
Related products:
Red Hat FuseRed Hat OpenShift

Share:

    Red Hat Fuse is a leading integration platform, which is capable of solving any given problem with simple enterprise integration patterns (EIP).  Over time, Red Hat Fuse has evolved to cater to a wide range of infrastructure needs.

    • Fuse on Red Hat OpenShift
    • Fuse standalone
      • Spring Boot
      • Apache Karaf
      • JBoss EAP

    For more information on each of these, check out the Red Hat Fuse documentation. The Fuse on Red Hat OpenShift flavor uses a Fuse image that has runtime components packaged inside a Linux container image.  This article will discuss how to reduce the size of the Fuse image. The same principle can be used for other images.

    Deep dive

    Before reducing the size, we need to first understand the basics of the Fuse container image provided by Red Hat.

    Let's dive into the Fuse image to understand its layers at a high level.  The following diagram shows six critical layers. Note, that for the sake of simplification, I have merged layers into one logical layer. For instance, Environment and Labels are shown as one layer, which provides the Metadata information.

    Current Fuse Image layeringFigure 1: High-level image layers of Red Hat Fuse images.

    The current version of the Red Hat Fuse image is about 171.8 MB in size. In Figure 1, we can see several layers. Each layer can be replaced by various alternatives.  That's good, but how do we know what the alternatives are?

    Let's take an example. Red Hat released a new Universal Base Image in April, and it's generally offered in two versions:

    1. Standard Red Hat base image — Contains a robust set of software features like yum, utils, and more.
    2. Minimal Red Hat base image — This is a stripped-down version. Some alternatives are provided, such as microdnf for software installation.

    The Minimal version is about half the size of the Standard Red Hat base image. This can be used as a replacement for the "openjdk18-rhel7" layer in a Fuse image. But this version cannot be used as is, because it does not contain JVM.

    Let's use the headless Open JDK to keep the JRE light. The image file will look like this:

    FROM registry.access.redhat.com/ubi7/ubi-minimal:7.7-98
    MAINTAINER Pramod Padmamabhan[ppadmana@redhat.com]
    
    #Adding env details
    ENV FIS_JAVA_IMAGE_NAME="jboss-fuse/minimal-fuse-openshift" \
    FIS_JAVA_IMAGE_VERSION="7.7-98" \
    PATH=$PATH:"/usr/local/s2i" \
    JAVA_DATA_DIR="/deployments/data" # BASE version information
    LABEL name="$FIS_JAVA_IMAGE_NAME" \
    version="$FIS_JAVA_IMAGE_VERSION" \
    architecture="x86_64" \
    summary="Platform for building and running plain Java applications (fat-jar and flat classpath)" \
    com.redhat.component="jboss-fuse-x-fuse-java-openshift-container" \
    io.fabric8.s2i.version.maven="3.3.3-1.el7" \
    io.k8s.description="Platform for building and running plain Java applications (fat-jar and flat classpath)" \
    io.k8s.display-name="Fuse Integration Services - Java" \
    io.openshift.tags="builder,java" \
    io.openshift.s2i.scripts-url="image:///usr/local/s2i" \
    io.openshift.s2i.destination="/tmp" \
    org.jboss.deployments-dir="/deployments" \
    description="Fuse Base Image With minimal UBI" \ group="ubi-minimal"
    
    USER root
    ADD run-java/ /opt/run-java
    ADD s2i/ /usr/local/s2i
    ADD jolokia /opt/jolokia #install OpenJDK 1.8 / use only when getting ubi minimal image
    RUN microdnf --enablerepo=rhel-7-server-rpms install java-1.8.0-openjdk-headless \
    && microdnf clean all \
    && echo securerandom.source=file:/dev/urandom >> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/lib/security/java.security \
    && useradd -r jboss \
    && usermod -g root -G jboss jboss \
    && chmod -R 755 /opt/run-java ; chmod -R 755 /usr/local/s2i \
    && mkdir -p /deployments/data \
    && chmod -R "g+rwX" /deployments \
    && chown -R jboss:root /deployments \
    && chmod 444 /opt/jolokia/jolokia.jar \
    && chmod 755 /opt/jolokia/jolokia-opts \
    && chmod 775 /opt/jolokia/etc \
    && chgrp root /opt/jolokia/etc
    
    #fis user
    USER 185
    CMD [ "/usr/local/s2i/run" ]

    For the complete source and library of the minimal-UBI project, refer to the GitHub repo.

    Building the above will generate a Fuse image of about 130 MB. Compared to the original Fuse image size of 171.8 MB. We have reduced the image by about 40 MB in size.

    What's next?

    The size reduction is good, but every custom change comes with a few drawbacks. In this case, we need to manage the S2i, Jolokia, and any other libraries or scripts we add to the UBI. Coming up, I will show how to reduce the Final-S2i image size. Until then, happy open sourcing!

    Last updated: July 1, 2020

    Recent Posts

    • GuideLLM: Evaluate LLM deployments for real-world inference

    • Unleashing multimodal magic with RamaLama

    • Integrate Red Hat AI Inference Server & LangChain in agentic workflows

    • Streamline multi-cloud operations with Ansible and ServiceNow

    • Automate dynamic application security testing with RapiDAST

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue