However, this also builds all other images, including ones which don't need to be built again and could result in images which were already tagged being replaced accidently. To fix this a separate script could be used for the legacy images which only builds what is necessary.
The Action CI runs this line to build the legacy images: https://github.com/gchq/gaffer-docker/blob/53cbf18b5d428d4893ff548733100d8ed27d15e7/.github/workflows/release.yaml#L112
However, this also builds all other images, including ones which don't need to be built again and could result in images which were already tagged being replaced accidently. To fix this a separate script could be used for the legacy images which only builds what is necessary.