You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While thinking on how to improve the current build system for the ubuntu docker image, I came up with the idea of using multistage builds. Our current image build system depends too much on github runners (it is not practical to build it locally); using this, it can be more easy to build containers locally.
Why improve the building process?
Several reasons:
It is not replicable locally. Right now we depend too much on Github for that. We need to be able to generate a docker image locally. Having a multistage docker file allow us put in there all the logic regarding installing and manipulating MAPDL. Additionally, it provides layers/images caching so the building could be faster when iterating.
We should avoid fragmentation between the docker building documentation (in this repo) and the actual docker files (in another internal repo). We should consider the option of either...
Pull the docker image from pymapdl repo.
Open the other repo so we leave the real docker file available to everybody.
Better parametrization. We need docker images with different MPI implementations, tools (python, git, etc), ... Multistage building allow us to generate a default stage... and then remove (MAPDL files)/add (tools) stuff into it to generate other docker images.
We need to sort out the tagging/releasing of docker images. We have right now a parallel process, which is fine. But we are forced to handle several docker files. And we are not correctly having releases which can clarify which are the changes in each docker image.
Todo
I need to document this and implement it internally in our internal repo.
Following the current implementation where we install MAPDL first, and then copy the files to the building context, we can do similar.
We will have two stages:
builder stage where we copy the installation files and install MAPDL.
container stage where we copy the installed files to.
Process
Download the ansys installation files from customer portal, and locate them in the working directory:
If you are building on a different architecture (for instance you are using a MacOS MX to build a container Intel/AMD arch based), you need to add --platform="linux/amd64":
We should implement a check in our CICD that makes it fail if the size of the layer is much.
#!/bin/bash# The name or ID of the Docker image
IMAGE_NAME="$1"# Size limit in bytes (5 GB = 5 * 1024^3 bytes)
SIZE_LIMIT=$((5*1024**3))# Get the size of the Docker image in bytes
IMAGE_SIZE=$(docker image inspect "$IMAGE_NAME" --format='{{.Size}}')# Convert bytes to GB for display
IMAGE_SIZE_GB=$(echo "scale=2; $IMAGE_SIZE / (1024^3)"| bc)# Check if the image size exceeds the limitif [ "$IMAGE_SIZE"-gt"$SIZE_LIMIT" ];thenecho"The Docker image '$IMAGE_NAME' exceeds 5 GB (size: ${IMAGE_SIZE_GB} GB)."exit 1
elseecho"The Docker image '$IMAGE_NAME' is within the size limit (size: ${IMAGE_SIZE_GB} GB)."exit 0
fi
Writing this here so it can be open to everybody.
Context
While thinking on how to improve the current build system for the ubuntu docker image, I came up with the idea of using multistage builds. Our current image build system depends too much on github runners (it is not practical to build it locally); using this, it can be more easy to build containers locally.
Why improve the building process?
Several reasons:
Todo
I need to document this and implement it internally in our internal repo.
Pinging @dts12263 @koubaa for visibility.
Logic
Following the current implementation where we install MAPDL first, and then copy the files to the building context, we can do similar.
We will have two stages:
builder
stage where we copy the installation files and install MAPDL.container
stage where we copy the installed files to.Process
Download the ansys installation files from customer portal, and locate them in the working directory:
And having the following docker file
Dockerfile.multistage
:You can build a working image `` using:
If you are building on a different architecture (for instance you are using a MacOS MX to build a container Intel/AMD arch based), you need to add
--platform="linux/amd64"
:You can test it with
docker run -it test_multi /bin/bash
.Notes/Caveats
.dockerignore
file will have to be applieds as a shell script:The text was updated successfully, but these errors were encountered: