Oracle APEX Stack on Docker
Tags: oracle, oracleapex, docker, devops
Published: 2020-08-23 20:47:49

Oracle APEX Stack
=================
1. [Oracle APEX](#oracle-apex)
2. [Prerequisites](#prerequisites)
3. [The Setup](#the-setup)
4. [Oracle APEX Stack Up!](#oracle-apex-stack-up)
5. [Oracle APEX Stack Down!](#oracle-apex-stack-down)
6. [Optional: Custom Setup](#optional-custom-setup)
7. [Credits](#credits)

## Oracle APEX

**Oracle APEX** is the most popular low-code development platform that enables you to build enterprise apps 20x faster with 100x less code. APEX lets developers quickly develop and deploy enterprise-grade apps that are highly secure out of the box.

It is easy to start to develop APEX apps; however, install and configure an APEX environment from scratch can be overwhelming for beginners.

This post will give you the simplicity you are looking to deploy an entire Oracle APEX dev/test environment in your laptop or the cloud using Docker. 

Another day I will make a post about Oracle APEX In-depth but now let focus on deployment.

Before anything else, let's see all the options we have to deploy Oracle APEX. 

| Deployments                | PROs                                                                                                                       | CONs                                                                                                                                                                                                                                            | How to get started                                                                        |
|----------------------------|----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| apex free workspace        | Easy to use to start testing APEX and to make a concept of proof in APEX.                                                  | - Not for commercial apps <br> - No direct access to the database <br> - Not all the features of a full APEX Development Environment                                                                                                            | Request a service [here](https://apex.oracle.com/pls/apex/f?p=4700&p_lang=en)               |
| Oracle APEX VM Image       | Easy to have a full APEX Development in your laptop if you like VMs.                                                       | - VMs can be overwhelming <br> - VM is pre-configured and not tuned for all APEX capabilities                                                                                                                                                    | Download the VM [here](https://www.oracle.com/database/technologies/databaseappdev-vm.html) |
| Oracle APEX On-Premises    | The best option to consider if you want a full APEX Development Environment with all the features in your laptop or Cloud. | It's not that easy to set up than other options                                                                                                                                                                                                 | keep reading                                                                              |
| Oracle Autonomous Database | The best option for Cloud hosting for APEX.                                                                                | There are restrictions and Limitations for APEX with Autonomous Database, see the entire list [here](https://docs.oracle.com/en/cloud/paas/autonomous-data-warehouse-cloud/user/apex-restrictions.html#GUID-E13D5044-B9DD-4168-8A12-C99532940DA9) | Start your Oracle Cloud journey right away [here](https://www.oracle.com/cloud/free/)      |

### Prerequisites 

Before starting, you need the following:
  * Docker Engine
    > You can install Docker Desktop on your laptop [here](https://docs.docker.com/engine/install/) <br>
    > If you are using Linux, you can install Docker Engine [here](https://docs.docker.com/engine/install/)
  
  * This guide requires docker-compose. If you don’t have it yet, take a look at the [installation instructions](https://docs.docker.com/compose/install/#install-compose) and get it.
    > If you’re installing docker-compose on CoreOS, it needs to go into `/opt/bin` instead of `/usr/local/bin`.
  
  * At least 20G of disk space and 4G of memory is recommended.
  * An internet connection.

## The Setup

First of all, let download or clone the GitHub repository that accompanies this guide.
```yaml
git clone https://github.com/reybis/oracle-apex-docker-stack.git
```

Due to licensing restrictions, I can’t host the software files in Github or elsewhere. _As such, you’ll need to download them manually. Download the following files and store them in the respective **software folder**._
  - [apex_20.1.zip](http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html)
  - [LINUX.X64_193000_db_home.zip](https://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html)
  - [apache-tomcat-9.0.37.tar.gz](https://tomcat.apache.org/download-90.cgi)
  - [OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz](https://adoptopenjdk.net/releases.html?variant=openjdk11&jvmVariant=hotspot)
  - [ords-20.2.0.178.1804.zip](http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html)
  - [sqlcl-20.2.0.174.1557.zip](http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html)

When you download the **repo** and all the **software files**, the directory structure needs to be like the following.
```toml
.
.gitignore
LICENSE.md
README.md
docker-compose.yml
preview.gif
ol7_ords
  ├── Dockerfile
  ├── README.md
  ├── scripts
  │   ├── healthcheck.sh
  │   ├── install_os_packages.sh
  │   ├── ords_software_installation.sh
  │   ├── server.xml
  │   └── start.sh
  └── software
      ├── apache-tomcat-9.0.37.tar.gz
      ├── apex_20.1.zip
      ├── OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz
      ├── ords-20.2.0.178.1804.zip
      ├── put_software_here.txt
      └── sqlcl-20.2.0.174.1557.zip
ol7_19
  ├── Dockerfile
  ├── README.md
  ├── scripts
  │   ├── healthcheck.sh
  │   └── start.sh
  └── software
      ├── apex_20.1.zip
      ├── LINUX.X64_193000_db_home.zip
      └── put_software_here.txt
```

## Oracle APEX Stack Up!
With all the files in place, you can create the stack using the following command.
```
docker-compose up
```
_If you want to be in detached mode use `-d` after the `up` command_

The `docker-compose` command creates the following services:
  - **[DB]** - Oracle Enterprise Database with Oracle APEX installed
  - **[ORDS]** - ORDS/Tomcat
  - **[PORTAINER]** - Portainer to manage the stack

Some things to keep in mind:
  - The **database** is created the first time the service **DB** is started, and also APEX is installed, which means it can take some time to be fully operational.
  > The **DB** service expose port `1521`.
  
  - The **ORDS** service depends on the **DB** service.
  
  > The **ORDS** service expose port `8080` and `8443`.
  
  - The **PORTAINER** service doesn't create the admin user, you will need to create it manually when access to `localhost:9000`
  > The **PORTAINER** service expose port `9000`.
  
  - A folder called **volumes** will be created to persist the database files and ORDS/Tomcat files.

After the `docker-compose` command succeeded, you can view the stack by accessing portainer at `localhost:9000` or by issuing the following command:
```
docker-compose ps
```

![](https://raw.githubusercontent.com/reybis/oracle-apex-docker-stack/master/preview.gif)

That's it, now you have an entire Oracle APEX Environment in your machine, and you can access it at `localhost:8080`.

## Oracle APEX Stack Down!
If you are done with your work and want to stop the stack, you can do it with the following command:
```
docker-compose down
```

## Optional: Custom Setup
If you like to change some environment settings like volumes, passwords, service names for the database, or many others, you can easily change it in the **docker-compose file**.

Open the `docker-compose.yml` file and change the environment and volume sections on both services:

**ORDS**
```
...
environment:
  - DB_HOSTNAME=db
  - DB_PORT=1521
  - DB_SERVICE=pdb1
  - APEX_PUBLIC_USER_PASSWORD=ApexPassword1
  - APEX_TABLESPACE=APEX
  - TEMP_TABLESPACE=TEMP
  - APEX_LISTENER_PASSWORD=ApexPassword1
  - APEX_REST_PASSWORD=ApexPassword1
  - PUBLIC_PASSWORD=ApexPassword1
  - SYS_PASSWORD=SysPassword1
  - KEYSTORE_PASSWORD=KeystorePassword1
volumes:
  - ./volumes/ol7_19_ords_tomcat:/u01/config/instance1
...
```

**DB**
```
...
environment:
  - SYS_PASSWORD=SysPassword1
  - PDB_PASSWORD=PdbPassword1
  - APEX_EMAIL=me@example.com
  - APEX_PASSWORD=ApexPassword1
volumes:
  - ./volumes/ol7_19_ords_db:/u02
...
```

## Credits
Bunch of ideas from Oracle-base docker files by [Tim Hall](https://github.com/oraclebase/dockerfiles).