Oracle Database setup on M1 Mac - v22-appfactory/appfactory-wiki GitHub Wiki

This guide will walkthrough the steps to setup an Oracle database instance on the M1 Mac and connect to a Node.js application.

Install Colima:

  1. Uninstall Docker desktop if it is already installed.
  2. Using Homebrew or another package manager, install Colima. More info at https://github.com/abiosoft/colima
# Homebrew
brew install colima

# MacPorts
sudo port install colima

# Nix
nix-env -iA nixpkgs.colima
  1. Reinstall Docker desktop
  2. Confirm you are in the correct docker context by running:
docker context ls
  1. Start a Colima instance with at least 21 GB of disk space and 2 GB of memory.
colima start --cpu 1 --memory 2 --disk 21

Install Oracle database

  1. Navigate to the Oracle container registry and create a free account if you do not have one.
  2. Go to the enterprise database container page and accept the user license agreement for the database container.
  3. Login to Oracle through Docker in your terminal.
  4. Pull and start a prebuilt Oracle database image from the Oracle image repository by running command:
docker run -d --name <container_name> \
 -p <host_port>:1521 -p <host_port>:5500 \
 -e ORACLE_SID=<your_SID> \
 -e ORACLE_PDB=<your_PDBname> \
 -e ORACLE_PWD=<your_database_password> \
 -v [<host_mount_point>:]/opt/oracle/oradata \
container-registry.oracle.com/database/enterprise:19.3.0.0

Note: This container will take a while to start, around 45 minutes to 1 hour. After a successful start, the container status will be ‘healthy’

Install Node.js for both CPU architectures

Install Node.js x86

  1. Uninstall all versions of Node.js
  2. Install Rosetta 2 if not already installed
  3. Run the following install command from a native (ARM) terminal:
# See https://github.com/nvm-sh/nvm#installing-and-updating
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
# Don't forget to source the command in your shell profile to make it available in new terminals!
  1. From Rosetta Terminal (tick checkbox in Terminal right click menu -> Get Info -> Open using Rosetta)
  2. To verify you are running in Rosetta run:
arch
-> i386
  1. Install node. Run:
nvm install lts/fermium

# Verify node installation
nvm use lts/fermium
node -e 'console.log(process.arch)'
-> x64

Install Node.js ARM

  1. Open a native terminal if not open already, verify you are running natively:
arch
-> arm64
  1. Install Node
nvm install stable
  1. Verify installation:
nvm use stable
node -e 'console.log(process.arch)'
-> arm64

Optional:

# To make DX a bit better you can alias your installations:
nvm alias arm stable
# arm -> stable (-> v15.6.0)
nvm alias intel lts/fermium
# intel -> lts/fermium (-> v14.15.4)

# To test aliases:
nvm use arm
# Now using node v15.6.0 (npm v7.4.0)
node -e 'console.log(process.arch)'
-> arm64
nvm use intel
# Now using node v14.15.4 (npm v6.14.10)
node -e 'console.log(process.arch)'
-> x64

Install Oracle Instant Client

  1. Download Instant Client from Oracle.
  2. Follow install instructions on the bottom of the same link as the download.

NOTE: make sure you are using a Rosetta terminal for this install.

Install node-oracledb

  1. Use lts/fermium version of installed node.js
  2. Run ‘npm install node-oracledb’. Note: if using TypeOrm or Knee.js, node-oracledb is included and you only need to install one of those ORM’s

Further reading:

  1. https://learncodeshare.net/2019/08/27/howto-connect-your-nodejs-app-in-docker-to-your-oracle-database/
⚠️ **GitHub.com Fallback** ⚠️