JVM containers are crashing on M4 Macbooks. This causes the PG Adapter for Cloud Spanner to crash and makes running the proxy impossible on ARM64. This gist explores how to overcome this by emulating x86 using Rosetta.
- Enable Rosetta 2
softwareupdate --install-rosettaThe output logs should end with the line
Install of Rosetta 2 finished successfully
services:
emulator:
image: gcr.io/cloud-spanner-emulator/emulator
restart: unless-stopped
container_name: spanner-emulator
ports:
- '9010:9010' # gRPC
- '9020:9020' # REST
pgadapter:
depends_on:
emulator:
condition: service_started
# JVM crashes on M4 chips https://github.com/docker/for-mac/issues/7583
platform: linux/amd64
image: 'gcr.io/cloud-spanner-pg-adapter/pgadapter'
restart: unless-stopped
container_name: pgadapter-connected-to-emulator
command:
- '-p emulator-project'
- '-i test-instance'
- '-r autoConfigEmulator=true'
- '-e emulator:9010'
- '-c ""' # no credentials
- '-x'
ports:
- '5433:5432' # pgwireRun docker compose up -d then access the emulated spanner using any postgres client.