Building Docker Images from Source¶
This documentation explains how to build the Fed-BioMed Docker images from scratch. It will guide you through the necessary steps to create each image, customize build parameters such as user settings and version tags, and ensure proper version compatibility across the components. Whether you are building images for development, customization, or deployment, this guide will help you get started.
Building Images¶
Docker images are located in the docker directory at the root of the Fed-BioMed repository. This directory contains subdirectories, each corresponding to a different Fed-BioMed component:
- Base: A minimal Docker image with the core Fed-BioMed installation and essential binaries.
- Node: The Docker image for the Fed-BioMed Node component.
- Researcher: The Docker image for the Fed-BioMed Researcher component.
Build order
Docker images depend on each other, so it is important to respect the correct build order. The Base Docker image must be built first. After that, you can build the Node and Researcher images.
Fed-BioMed Base Image¶
First, please clone the Fed-BioMed repository and navigate to its root directory. All Docker build commands should be executed from this directory. The example below builds the base Docker image with the default user and settings:
git clone https://github.com/fedbiomed/fedbiomed.git
cd fedbiomed
docker build -t fedbiomed/base:<tag> . -f docker/base/Dockerfile
In some cases, you may want to customize the default user and group in the image. You can do this using build arguments as shown below:
docker build \
--build-arg FEDBIOMED_USER=<user-name> \
--build-arg FEDBIOMED_UID=<user-id> \
--build-arg FEDBIOMED_GROUP=<group-name> \
--build-arg FEDBIOMED_GID=<group-id> \
-t fedbiomed/base:<tag> ./ -f docker/base/Dockerfile
Once the base image is built with a custom user, all other Fed-BioMed Docker images that use this base image will inherit that user configuration
Tags
Please note that image tags are important to ensure that other images using the base image reference the correct version. By default, in the docker images the tag latest is used. Therefore, please use latest tag for <tag> if you want to follow default configuration.However, we recommend assigning appropriate and consistent tags when building images.
Building Node Images¶
As it is mentioned above, when building Docker images for Fed-BioMed components, it is essential to use consistent and appropriate tags across all images. The FBM_IMAGE_VERSION build argument allows you to specify which version (i.e., tag) of the base image should be used during the build process.
By default, if FBM_IMAGE_VERSION is not provided, the tag latest will be used:
FROM fedbiomed/base:${FBM_IMAGE_VERSION:-latest}
This means that if you have built the base image with the tag latest, you don't need to explicitly set --build-arg FBM_IMAGE_VERSION=latest. However, if you used a custom tag (e.g., my-tag-or-version), you must pass the same tag to the dependent image builds to ensure compatibility.
Building the Node Image¶
docker build \
--build-arg FBM_IMAGE_VERSION=<tag> \
-t fedbiomed/node:<tag> ./ -f docker/node/Dockerfile
Building the Researcher Image¶
Just like the node images, the researcher image depends on the base image tag. Ensure you pass the correct tag using the FBM_IMAGE_VERSION build argument:
docker build \
--build-arg FBM_IMAGE_VERSION=<tag> \
-t fedbiomed/researcher:<tag> ./ -f docker/researcher/Dockerfile
After all images are built, please refer to the Fed-BioMed Docker deployment documentation for guidance on how to run and configure these containers.