From 971bab4c2f58189c96fe7bbe8436efdfb6c6cb1a Mon Sep 17 00:00:00 2001 From: BlueFox Date: Sat, 21 Sep 2024 16:13:28 +0000 Subject: [PATCH] Added multiplatform build and push instructions --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2826bef..0f1ada0 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,38 @@ To build the container to an image called "cmatrix-demo", run ```sh docker build -t cmatrix-demo . -``` \ No newline at end of file +``` + +## Multi-platform builds + +To do a build for multiple architectures, run: + +```sh +sudo docker buildx create --name buildx-multi-arch +sudo docker buildx use buildx-multi-arch +``` + +Then, to build it (e.g. for amd64 and arm64/v8): + +```sh +sudo docker buildx build --no-cache --platform linux/amd64,linux/arm64/v8 -t cmatrix-demo . +``` + +**Please note that this will not load the images into the local image store (because it's obviously hard to run images built for the wrong architecture)! For uploading this to a container registry, see below.** + + +## Pushing the container to a registry + +As you've got everything working, maybe it's time to share the work! This can be done by uploading the built image to a docker container registry, e.g. [Docker Hub](https://hub.docker.com/). + +First, sign into your Docker Hub account with your local docker installation (to create an account head to [https://app.docker.com/signup](https://app.docker.com/signup) in your favourite browser). The procedure is self-explaining: + +```sh +docker login +``` + +To build and push the image directly to Docker Hub, use the following command (differs from the one above only in the --push option): + +```sh +sudo docker buildx build --no-cache --platform linux/amd64,linux/arm64/v8 -t /cmatrix-demo . --push +```