Skip to content

Oracle on Mac ARM64

Chris Bono edited this page Nov 7, 2023 · 9 revisions

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.

Overview

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).

Steps

Pre-requisites

Verify Homebrew

Warning
If Homebrew is not installed properly for M1/M2 you will run into issues w/ Colima.

Execute which homebrew and…​

  • if the result is empty then install Homebrew

  • if the result is under /usr/local/bin then uninstall and then install Homebrew

  • if the result is under /opt/homebrew skip to next step

Install Colima

Execute brew install colima

Run Colima

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

Run container in Docker

  • 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

Run container in Testcontainers

  • 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

Running Dataflow locally against Oracle

  • 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

Useful aliases

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 "