launchbadge / sqlx

🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite.
Apache License 2.0
13.15k stars 1.24k forks source link

Docker compose up testing (instructions) should work on Apple Silicon #2724

Open kriswuollett opened 1 year ago

kriswuollett commented 1 year ago

Is your feature request related to a problem? Please describe.

Cannot run Docker tests on macoOS / Apple M2. I get errors like:

image with reference mariadb:10.3 was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64/v8

Describe the solution you'd like

The tests/docker-compose.yml should also be accompanied by overlays so that the platform can be specifically set, e.g., linux/arm64 since not everything is available on linux/arm64/v8.

Describe alternatives you've considered

None

Additional context

None

grooverdan commented 1 year ago

Looks like a compose issue and you might need to specifiy the env variable to work for you. DOCKER_DEFAULT_PLATFORM=linux/arm64

kriswuollett commented 1 year ago

Looks like a compose issue and you might need to specifiy the env variable to work for you. DOCKER_DEFAULT_PLATFORM=linux/arm64

Thanks for pointing out DOCKER_DEFAULT_PLATFORM environment variable. That's a reasonable thing to put in the docs if that more or less how the CI is intended to be run (implied x86_64 only due to runner availability:

https://github.com/launchbadge/sqlx/blob/487b89a4b6c67aacd7c15b0814a450801333153c/.github/workflows/sqlx.yml#L236-L243

I never had to learn about DOCKER_DEFAULT_PLATFORM environment variable earlier since I sometimes mix arm and x86 services in the same compose file so always went with platform setting to begin with. But if the intention was to let a developer get running tests right away against their deployment platform, arm more and more likely these days, then the compose up command should work out of the box, and hide the compatibility complexity by potentially using overlays in CI.

kriswuollett commented 1 year ago

Updated title to avoid suggesting a specific solution

grooverdan commented 1 year ago

Its still sounds like a docker problem for pulling the wrong architecture. Does a unit test of docker pull mariadb:10.3 result in an amd64 image? what about 10.11 (both should support arm but maybe manifest info has been updated)? Is it a recent docker version? Check https://github.com/docker/for-mac/issues.

An alternate is https://podman.io/docs/installation#macos