pact-foundation / pact-ruby-cli

Amalgamated Pact Ruby CLI
https://pact.io
MIT License
12 stars 15 forks source link

Docker pactfoundation/pact-cli is not compatible with arm64 #104

Closed gergo83 closed 1 year ago

gergo83 commented 1 year ago

Hi Team,

Thank you very much for this great product. It helps a lot to my company.

I'm using a M1 mac book and tried to run the latest pactfoundation/pact-cli image on my local machine to verify some pacts, but unfortunately the image is not supported on my architecture.

Can you please release it to ARM64 architecture?

Thank you, Gergo

YOU54F commented 1 year ago

Hey @gergo83

Sorry if this comment confused you

https://github.com/pactflow/docs.pactflow.io/issues/227#issuecomment-1540753894

There is already an issue requesting this functionality #51 and a PR implementing it #98 so I will close this as a duplicate of #51

You can trial it out today https://hub.docker.com/r/you54f/pact-cli/tags

You can also use the official image by setting the platform --platform linux/amd64

eg

docker run --rm \
  --platform linux/amd64 \
  -e PACT_BROKER_BASE_URL  \
  -e PACT_BROKER_USERNAME  \
  -e PACT_BROKER_PASSWORD  \
  pactfoundation/pact-cli:latest \
  publish \
  /pact/example/pacts \
  --consumer-app-version fake-git-sha-for-demo-$(date +%s)

I had this intercept in my .zshrc file for a long while, but have since been moving over to arm based images. The platform flag above gives you the ability to change platform on demand, the bash function below in a .zshrc file will intercept for all docker commands, meaning you'll be running everything in emulation mode (which is probably not what you want)

# # useful only for Mac OS Silicon M1, 
# # still working but useless for the other platforms
docker() {
 if [[ `uname -m` == "arm64" ]] && [[ "$1" == "run" || "$1" == "build" ]]; then
    /usr/local/bin/docker "$1" --platform linux/amd64 "${@:2}"
  else
     /usr/local/bin/docker "$@"
  fi
}
YOU54F commented 1 year ago

TL;DR

You can now get multi-platform images by appending -multi to your pact-cli Docker tag

ARM64

❯docker run --rm --platform=linux/arm64 -it pactfoundation/pact-cli:latest-multi /bin/sh -c 'uname -sm'
Unable to find image 'pactfoundation/pact-cli:latest-multi' locally
latest-multi: Pulling from pactfoundation/pact-cli
Digest: sha256:d0f8f7d47796cc33c5c47ef328bb1ba42685d4c7005dece026ea8363f9d3ce65
Status: Downloaded newer image for pactfoundation/pact-cli:latest-multi
Linux aarch64

AMD64

❯ docker run --rm --platform=linux/amd64 -it pactfoundation/pact-cli:latest-multi /bin/sh -c 'uname -sm'
Unable to find image 'pactfoundation/pact-cli:latest-multi' locally
latest-multi: Pulling from pactfoundation/pact-cli
Digest: sha256:d0f8f7d47796cc33c5c47ef328bb1ba42685d4c7005dece026ea8363f9d3ce65
Status: Downloaded newer image for pactfoundation/pact-cli:latest-multi
Linux x86_64

ARM

❯ docker run --rm --platform=linux/arm -it pactfoundation/pact-cli:latest-multi /bin/sh -c 'uname -sm'
Unable to find image 'pactfoundation/pact-cli:latest-multi' locally
latest-multi: Pulling from pactfoundation/pact-cli
Digest: sha256:d0f8f7d47796cc33c5c47ef328bb1ba42685d4c7005dece026ea8363f9d3ce65
Status: Downloaded newer image for pactfoundation/pact-cli:latest-multi
Linux armv7l
gergo83 commented 1 year ago

@YOU54F Thank you for letting me know :)