Skip to content

Allow for aarch64 (macOS & Apple Silicon) support in musicbrainz-docker #354

Description

@JDLH

When, on my macOS machine with an Apple Silicon CPU, I follow the instructions to set up a mirror MusicBrainz server with musicbrainz-docker, the Docker compose does not come up. The problem appears to be that the musicbrainz-docker images support only linux/amd64 architecture, and I need my containers to run on aarch64. I would like either the images from Metabrainz to support both architectures, or for the instructions to describe how to build with aarch64 emulation.

How to reproduce

  1. On a macOS machine with an Apple Silicon CPU, follow the instructions to set up a mirror MusicBrainz server with musicbrainz-docker.
  2. In the Build Docker images step, run the command,
docker compose up

Observed behaviour
The docker compose up command fails with this message (line break added for readability):

target db: failed to solve: metabrainz/musicbrainz-docker-db:18-build0: failed to resolve source metadata for 
docker.io/metabrainz/musicbrainz-docker-db:18-build0: no match for platform in manifest: not found

Expected behaviour
The docker compose up command succeeds.

Discussion
I know very little about Docker, so I cannot really suggest the best approach for supporting aarch64.

I notice that the build directory contains two subdirectories, build/postgres-prebuilt and build/postgres. The docker-compose.yml lines 14-17 refers to build/postgres-prebuilt/. It might be helpful to have an alternate config somewhere that refers to build/postgres/.

I was able to build containers with QEMU emulation for aarch64 using through a different build command, plus some docker-compose.yml configuration changes:

docker buildx build --build-arg POSTGRES_VERSION=18 --build-arg DB_BUILD_SEQUENCE=0 --platform linux/amd64 -t musicbrainz-db:latest build/postgres

And in docker-compose.yml, remove the build: section and use only image::

services:
  db:
    image: musicbrainz-db:latest

Note that the docker buildx command prints its own warning message:

 1 warning found (use docker --debug to expand):
 - UndefinedVar: Usage of undefined variable '$POSTGRES_IMAGE_TAG' (line 7)

Why? the build/postgres/Dockerfile, lines 1-7, reads,

ARG POSTGRES_VERSION=18
ARG POSTGRES_IMAGE_VARIANT=trixie
ARG POSTGRES_IMAGE_TAG=${POSTGRES_VERSION}-${POSTGRES_IMAGE_VARIANT}
FROM postgres:${POSTGRES_IMAGE_TAG}

ARG POSTGRES_VERSION
LABEL org.metabrainz.based-on-image="postgres:${POSTGRES_IMAGE_TAG}"

Apparently the values from the ARG statements don't persist after the FROM. There seems to be no good way to make them persist. The solution seems to be to redeclare the ARGs in build/postgres/Dockerfile to be:

ARG POSTGRES_VERSION=18
ARG POSTGRES_IMAGE_VARIANT=trixie
ARG POSTGRES_IMAGE_TAG=${POSTGRES_VERSION}-${POSTGRES_IMAGE_VARIANT}
FROM postgres:${POSTGRES_IMAGE_TAG}

ARG POSTGRES_VERSION=18
ARG POSTGRES_IMAGE_VARIANT=trixie
ARG POSTGRES_IMAGE_TAG=${POSTGRES_VERSION}-${POSTGRES_IMAGE_VARIANT}
LABEL org.metabrainz.based-on-image="postgres:${POSTGRES_IMAGE_TAG}"

I notice that the Docker.desktop app tags the indexer and search containers, as well as the db container, with a red "AMD64" tag. However, I only had to perform the buildx workaround above for the db container.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions