From 8ddb6d7821caed772c0325c2cbc670908cdc4f74 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Tue, 11 Oct 2022 12:29:33 +0200 Subject: [PATCH] feat: add multi-platform Docker images (#3354) * add arm platform to the build * add a note about multi-platforms build * test on current branch * setup qemu on Github actions * better naming * Revert "test on current branch" This reverts commit b0e5ea77b46e3e0bafd579c95e434c6a3c8ef84f. --- .github/workflows/docker_release.yml | 5 ++++- docker/README.md | 15 +++++++++++++++ docker/docker-bake.hcl | 11 ++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker_release.yml b/.github/workflows/docker_release.yml index f0675796b..d649ccb63 100644 --- a/.github/workflows/docker_release.yml +++ b/.github/workflows/docker_release.yml @@ -1,4 +1,4 @@ -name: Release Docker images +name: Docker image release on: workflow_dispatch: @@ -19,6 +19,9 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 diff --git a/docker/README.md b/docker/README.md index 57a1f2d5b..6cf92811d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -36,6 +36,21 @@ images, for example if you want to use a branch from the Haystack repo: HAYSTACK_VERSION=mybranch_or_tag BASE_IMAGE_TAG_SUFFIX=latest docker buildx bake gpu --no-cache ``` +### A note about multi-platform builds + +Haystack images support multiple architectures, but depending on your operating system and Docker +environment you might not be able to build all of them locally. If you get an error like: +``` +multiple platforms feature is currently not supported for docker driver. Please switch to a different driver +(eg. “docker buildx create --use”) +``` + +you might need to override the `platform` option and limit local builds to the same architecture as +your computer's. For example, on an Apple M1 you can limit the builds to ARM only by invoking `bake` like this: +```sh +docker buildx bake base-cpu --set "*.platform=linux/arm64" +``` + # License View [license information](https://github.com/deepset-ai/haystack/blob/main/LICENSE) for diff --git a/docker/docker-bake.hcl b/docker/docker-bake.hcl index ea4d5e10a..dca3d101b 100644 --- a/docker/docker-bake.hcl +++ b/docker/docker-bake.hcl @@ -38,8 +38,6 @@ group "all" { targets = ["base", "base-gpu", "cpu", "gpu"] } -target "docker-metadata-action" {} - target "base-cpu" { dockerfile = "Dockerfile.base" tags = ["${IMAGE_NAME}:base-cpu-${IMAGE_TAG_SUFFIX}"] @@ -50,6 +48,7 @@ target "base-cpu" { haystack_extras = notequal("",HAYSTACK_EXTRAS) ? "${HAYSTACK_EXTRAS}" : "[docstores,crawler,preprocessing,ocr,onnx,beir]" torch_scatter = "https://data.pyg.org/whl/torch-1.12.0+cpu.html" } + platforms = ["linux/amd64", "linux/arm64"] } target "base-gpu" { @@ -62,6 +61,7 @@ target "base-gpu" { haystack_extras = notequal("",HAYSTACK_EXTRAS) ? "${HAYSTACK_EXTRAS}" : "[docstores-gpu,crawler,preprocessing,ocr,onnx-gpu,beir]" torch_scatter = "https://data.pyg.org/whl/torch-1.12.1%2Bcu113.html" } + platforms = ["linux/amd64", "linux/arm64"] } target "cpu" { @@ -70,11 +70,13 @@ target "cpu" { args = { base_image_tag = "base-cpu-${BASE_IMAGE_TAG_SUFFIX}" } + platforms = ["linux/amd64", "linux/arm64"] } target "cpu-latest" { inherits = ["cpu"] tags = ["${IMAGE_NAME}:cpu"] + platforms = ["linux/amd64", "linux/arm64"] } target "gpu" { @@ -83,12 +85,11 @@ target "gpu" { args = { base_image_tag = "base-gpu-${BASE_IMAGE_TAG_SUFFIX}" } - platforms = [ - "linux/amd64" - ] + platforms = ["linux/amd64", "linux/arm64"] } target "gpu-latest" { inherits = ["gpu"] tags = ["${IMAGE_NAME}:gpu"] + platforms = ["linux/amd64", "linux/arm64"] }