-
Notifications
You must be signed in to change notification settings - Fork 581
Oracle on Mac ARM64
There is currently no free Oracle database port readily available that can run on ARM64 architecture (Mac M1/M2). This makes it impossible for developers using these computers to exercise Oracle functionality/tests locally. This guide show how to work around this limitation.
The solution is to run a tool (Colima) that allows you to spin up x86_64
software on Apple M chips and then start the container as you normally would (docker run
or via Testcontainers).
Warning
|
If Homebrew is not installed properly for M1/M2 you will run into issues w/ Colima. |
Execute which homebrew
and…
No matter where you are running the container from, you must always have Colima started prior to running the container.
-
Run Colima w/ the following command:
colima start --arch x86_64 --memory 4
-
Ensure Colima is started (above)
-
Start the container w/ the following command:
docker run --name test-oracle -d -p 1521:1521 -e ORACLE_PASSWORD=spring -e APP_USER=spring -e APP_USER_PASSWORD=spring -e ORACLE_DATABASE=dataflow gvenzl/oracle-xe:18-slim-faststart
-
Stop the container w/ the following command:
docker stop test-oracle
-
Stop Colima w/ the following command:
colima stop
-
Ensure Colima is started (above)
-
Set the following environment variables:
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock export DOCKER_HOST="unix://${HOME}/.colima/docker.sock"
-
Create and start an
OracleContainer
in your tests such as:OracleContainer container = new OracleContainer(DockerImageName.parse("gvenzl/oracle-xe") .withTag("18-slim-faststart")); container.start();
-
Once you are finished running the container you can stop Colima w/ the following command:
colima stop
-
Ensure Oracle container running locally (above)
-
TODO NYI Include the Oracle driver by building Dataflow w/ the
local-dev-oracle
profile as follows:./mvnw clean install -DskipTests -s .settings.xml -Plocal-dev-oracle
-
Set the following env vars before running Dataflow:
export SPRING_DATASOURCE_URL=jdbc:oracle:thin:@localhost:1521/dataflow export SPRING_DATASOURCE_USERNAME=spring export SPRING_DATASOURCE_PASSWORD=spring export SPRING_DATASOURCE_DRIVER_CLASS_NAME=oracle.jdbc.OracleDriver
-
Run the Dataflow server either from w/in IDEA or
java -jar
Here are some useful aliases for starting/stopping an Oracle database in Docker:
alias oracle-start="docker run --name test-oracle -d -p 1521:1521 -e ORACLE_PASSWORD=spring -e APP_USER=spring -e APP_USER_PASSWORD=spring -e ORACLE_DATABASE=dataflow gvenzl/oracle-xe:18-slim-faststart"
alias oracle-stop="docker stop test-oracle "
alias oracle-kill="docker stop test-oracle && docker rm test-oracle "
alias colima-start="colima start --arch x86_64 --memory 4 "
alias colima-stop="colima stop "