An exercise in Discovery, Building Docker Images, using Makefiles & Docker Compose. — Part 3

George Leonard
3 min readAug 23, 2024

--

Let’s build Apache Hadoop DFS cluster.

(See: Part 2)

(23 August 2024)

Overview

This is going to be a rather short issue, below is the Dockerfile used to build our OpenJDK11 image.

We start of by using the FROM primitive again, but this time we specify our previously build base OS image (georgelza/ubuntu20.04:1.0.1).

As can be seen, we pretty much have the same logic as discussed in part 2, except we changed the value assigned to build_deps to specify openjdk11 the package.

The reason we do this as a separate build (vs including the OpenJDK11 as a package in the previous builds build_deps) is to allow us to use our base OS image from part 2 in other builds, i.e. we might need to build a OpenJDK8 application server also, which then means we can simply re-use the OS image for both, with simply the relevant application server version changed.

Sidetrack: In another project I build a Apache Hive Metastore (Blog for another day) which requires openjdk8, for that project all we need to do is change the version in the build_deps variable to build our base image.

The only addition here is we add an environment variable JAVA_HOME. As this is added to this image all images that will use this image will inherit the variable.

Note: by including the repo owner (georgelza) in this case it allows me to upload my images to Docker hub from where I can pull them when needed…

A Todo, Docker multi-platform builds. That’s where a single image name is assigned, but docker can build say both AMD64 and ARM64 images… There are more Architectures that can be build. This then allows anyone that issues a pull command to pull the right image for the right architecture, but now that’s a total new Rabbit hole for another day/blog.

FROM georgelza/ubuntu20.04:1.0.1

WORKDIR /root

ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64

# Install some useful tools
RUN echo "--> install Open JDK 11 ARM64" && \
build_deps="openjdk-11-jdk" && \
apt-get update && \
apt-get install -y $build_deps

RUN echo "--> Purge apt artifacts" && \
apt-get purge -y --auto-remove $build_deps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

To execute the build as per previous, execute “make build” in the “build-ubuntu-os-openjdk11” subdirectory. See the Makefile for the actual docker command executed. You will notice it is the same as the OS build except for the value assigned to IMAGE_NAME variable that has changed.

We now have a base Ubuntu 20.04 OS, with some useful tooling installed and OpenJDK 11 application server installed. This combination can be used for a large amount of the Apache Foundation projects available.

As per the README.md, we could consider using a smaller Ubuntu image like jammy… but that’s an exploration for another day. -> TODO

See you in Part 4 where we will start with the Apache Hadoop installation.

My Repo’s

All the code used during this article will be available on the below GIT repo.

Building Docker Images

About Me

I’m a techie, a technologist, always curious, love data, have for as long as I can remember always worked with data in one form or the other, Database admin, Database product lead, data platforms architect, infrastructure architect hosting databases, backing it up, optimizing performance, accessing it. Data data data… it makes the world go round.

In recent years, pivoted into a more generic Technology Architect role, capable of full stack architecture.

George Leonard

georgelza@gmail.com

--

--

George Leonard

I'm a techie, a technologist, technology architect, full stack architect, Always curious, Love data and data platforms.