Add IAR to MicroEJ SDK Docker Image

This document presents how to create a Dockerfile with MicroEJ SDK version 5.x and Cross-platform Build Tools for Arm to build a MicroEJ application. You can use this image in your automated CI.

Prerequisites

  • A recent version of IAR BXARM and its user licence.

This tutorial was tested with MicroEJ SDK 5.8.1-jdk11, IAR 9.30.1, and Docker 24.0.6.

Create the Dockerfile

Here is our final Dockerfile. We will explain each specific step below.

FROM microej/sdk:5.8.1-jdk11

USER root
SHELL ["/bin/bash", "-c"]

ARG IAR_BXARM_VERSION=9.30.1
ARG IAR_BXARM_PACKAGE="bxarm-$IAR_BXARM_VERSION.deb"

COPY ressources/$IAR_BXARM_PACKAGE /tmp/$IAR_BXARM_PACKAGE
RUN apt-get update && apt-get install sudo libsqlite3-0 libxml2 tzdata dos2unix /tmp/$IAR_BXARM_PACKAGE -y && \
    apt-get clean autoclean autoremove && rm -rf /var/lib/apt/lists/* /tmp/*.deb

ENV PATH="/opt/iarsystems/bxarm/arm/bin/:/opt/iarsystems/bxarm/common/bin/:$PATH"
ENV IAR_LICENSE_SERVER=$IAR_LICENSE_SERVER_IP

# Set workdir
WORKDIR ${HOME}

ADD run.sh /run.sh
RUN chmod a+x /run.sh

# Good practice, switch back to user.
USER ${user}

ENTRYPOINT ["/run.sh"]
  1. In a new directory create a file named Dockerfile.

  2. We use MicroEJ SDK base image, they are available on docker hub. In your Dockerfile add this code:

    FROM microej/sdk:5.8.1-jdk11
    
  3. Add IAR BXARM deb package in a directory named resources.

  4. Add the package info to your Dockerfile (update the version with the one you want to use):

    ARG IAR_BXARM_VERSION=9.30.1
    ARG IAR_BXARM_PACKAGE="bxarm-$IAR_BXARM_VERSION.deb"
    
  5. Copy the package to a temporary directory.

    COPY ressources/$IAR_BXARM_PACKAGE /tmp/$IAR_BXARM_PACKAGE
    
  6. Install this package along with any others required packages.

    RUN apt-get update && apt-get install sudo libsqlite3-0 libxml2 tzdata dos2unix /tmp/$IAR_BXARM_PACKAGE -y && \
    apt-get clean autoclean autoremove && rm -rf /var/lib/apt/lists/* /tmp/*.deb
    
  7. Set IAR path and license server address:

    ENV PATH="/opt/iarsystems/bxarm/arm/bin/:/opt/iarsystems/bxarm/common/bin/:$PATH"
    ENV IAR_LICENSE_SERVER=$IAR_LICENSE_SERVER_IP
    
  8. Finally create a run.sh script with the following content:

    lightlicensemanager setup -s license.iar.public
    exec "$@"