Creating Dockerfile

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

Please visit Docker's documentation on Dockerfile for further references and details.

Here's an example Dockerfile that we'll explore in details:

FROM debian:11-slim

WORKDIR /home

ARG runfile

ENV install_directory /home/omnisserver
ENV LD_LIBRARY_PATH ${install_directory}
ENV OMNIS_PORT 80

RUN apt-get -q -y update
RUN apt-get -q -y install \
    vim \
    lsof \
    htop \
    procps \
    sudo

COPY ${runfile} /
RUN chmod +x /${runfile}

RUN /${runfile} unattended \
    install-dependencies \
    stacks 5 \
    timeslice 20 \
    destination-dir "${install_directory}" \
    port ${OMNIS_PORT} \
    serial "SERIAL_NUMBER_WITHOUT_SPACES"

# Add startup libraries:
ADD libs /tmp/libs
RUN cp -R /tmp/libs/* ${install_directory}/startup
RUN rm -r /tmp/libs

EXPOSE ${OMNIS_PORT}

ENTRYPOINT ${install_directory}/homnis

At the beginning of our Dockerfile, we do FROM debian:11-slim which means we will use the slim version of Debian 11 as our base image.

You don't have to use the same version or distro, in fact you could use Ubuntu if you want to - the reason we decided to use a slim version of Debian is to have a base image as slim and as bare-bones as possible, so that we can install just what we need on top of it. See more at Docker.


WORKDIR /home

WORKDIR simply sets the container's current working directory as /home. See more at Docker.


ARG runfile

ARG defines an argument for the Dockerfile that takes the name of runfile. We use this to provide the path to the Omnis Headless .run file to our Dockerfile. See more at Docker.


ENV install_directory /home/omnisserver
ENV LD_LIBRARY_PATH ${install_directory}
ENV OMNIS_PORT 80

We use ENV to declare a few environment variables: the install directory which in this case will be /home/omnisserver, then we specify the install directory to the LD_LIBRARY_PATH to ensure any Omnis-specific libraries are found and finally create the OMNIS_PORT environment variable and set it to 80.

You can use any other port as you desire, up to 65535 (usually port numbers up to 1023 are reserved, 1024 to 49151 should be used for user server applications and 49152 to 65535 for clients).

See more about ENV at Docker.


RUN apt-get -q -y update
RUN apt-get -q -y install \
    vim \
    lsof \
    htop \
    procps \
    sudo

We use RUN to update our apt-get package indexes and then we invoke apt-get install (with some extra options such as -q and -y for quiet and automatically accept all the details) to install a few utilities such as vim, sudo and htop. These are useful for debugging issues on a running container.

See more about RUN at Docker.


COPY ${runfile} /
RUN chmod +x /${runfile}

We use COPY to make a copy of our .run file which we had passed in as an argument inside the container. Afterwards, we use chmod +x to give it the executable attribute.

See more about COPY at Docker.


RUN /${runfile} unattended \
    install-dependencies \
    stacks 5 \
    timeslice 20 \
    destination-dir "${install_directory}" \
    port ${OMNIS_PORT} \
    serial "SERIAL_NUMBER_WITHOUT_SPACES"

Once our .run file is an executable, we can launch it in unattended mode and pass it a few options such as the serial number and the port we wish it to run on. Please note we use the previously defined OMNIS_PORT environment variable.


ADD libs /tmp/libs
RUN cp -R /tmp/libs/* ${install_directory}/startup
RUN rm -r /tmp/libs

Once we installed the Omnis Headless server, we use the ADD command to add a folder named libs to the /tmp/libs location in the container. The libs folder must be local to the Dockerfile.

Afterwards, we copy the contents of the libs folder into the startup folder of our Omnis Headless installation and remove the libs folder because it's no longer needed.


EXPOSE ${OMNIS_PORT}

One of the final steps is to EXPOSE the port number which our Omnis Headless installation is running on. In this case, we use the previously defined OMNIS_PORT environment variable.

See more at Docker.


ENTRYPOINT ${install_directory}/homnis

Finally, we set our ENTRYPOINT as the homnis process. See more at Docker.