Skip to content

Dockerized APEX Workshop

Erik Espinoza edited this page May 15, 2018 · 15 revisions

Dockerized APEX Instance Workshop

Required Software in PC.

  • ssh client, recommended putty for Windows PC's.
  • sftp client, recommended Filezilla for Windows PC's.

All the commands will be executed from the connected user's home (/home/ubuntu).

cd ~

1. Adjust Swap Support in Docker for Ubuntu Hosts.

  1. With sudo edit the /etc/default/grub file. Add or edit the GRUB_CMDLINE_LINUX line to add the following two key-value pairs:

    GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
    
  2. Update GRUB.

    $ sudo update-grub
    
  3. Now lets do something fun, go to your OCI Console and push the Reboot button for your Virtual Machine.

  4. Once your Virtual Machine is back online log into it again πŸ˜„.

2. Install Docker.

We will be working with Ubuntu Xenial 16.04 (LTS).

Uninstall Old Versions.

$ sudo apt-get remove docker docker-engine docker.io

It’s OK if apt-get reports that none of these packages are installed.

Install Using the Repository.

  1. Update the apt Package Index.

    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS.

    $ sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        git \
            unzip \
        software-properties-common
    
  3. Add Docker’s official GPG key.

    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    

    Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

    $ sudo apt-key fingerprint 0EBFCD88
    

    Output should be like below:

    pub   4096R/0EBFCD88 2017-02-22
           Key fingerprint = `9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88`
    uid                  Docker Release (CE deb) <[email protected]>
    sub   4096R/F273FCD8 2017-02-22
    
  4. Set up the stable repository.

    $ sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"
    
  5. Update the apt package index.

    $ sudo apt-get update
    
  6. Install the latest version of Docker CE.

    $ sudo apt-get install docker-ce
    
  7. Add your user to the docker unix group.

    sudo usermod -aG docker ubuntu
    

    NOTE: After your user to the docker unix group you will have to logout from the session and log back in.

3. Get Oracle Database software

  1. Open in your browser https://edelivery.oracle.com and Sign In.

  2. In the search box type Oracle Database 12c Standard Edition 2 and click Search.

  3. From the list of results click on the link that says DLP: Oracle Database 12c Standard Edition 2 12.2.0.1.0 (Oracle Database Standard Edition 2).

  4. Click on the cart icon right next to search bar.

  5. Select only the item that says Oracle Database 12.2.0.1.0 and under the Platform/Languages field select Linux x86-x64 then click on the button Continue.

  6. Review and accept the terms and conditions then click on the button Continue.

  7. Click on the link that says WGET Options placed on the top and/or bottom on the right side.

  8. Click on the button Download .sh and save in local computer.

  9. Upload the file wget.sh to your Virtual Machine.

  10. Make wget.sh executable.

    $ chmod +x wget.sh
    
  11. Execute wget.sh.

    Very important you force the execution of wget.sh through bash by executing the command as below. Also once you run the command it could appear that nothing is happening since the wget.sh command is downloading in the background, in order to monitor the download process you could open a second ssh connection to the VM and tail -f the log (See below under Second ssh)

    Please note that the download process will take a couple minutes so be PATIENT πŸ˜„.

    $ bash wget.sh
    

    Second ssh connection:

    The wget.sh command will create a file wgetlog-<DATE AND TIME>.log where it will log the progress of download.

    tail -f wgetlog-<DATE AND TIME>.log
    
  12. Rename the downloaded file V839960-01.zip to linuxx64_12201_database.zip.

    $ mv V839960-01.zip linuxx64_12201_database.zip
    

NOTE: We know that the network might be sometimes slow so we temporary have made available the software via a public link and you can wget it directly from your VM. πŸ˜„

wget https://objectstorage.us-ashburn-1.oraclecloud.com/p/n--917neK4vHAX8vccdg-IkMmgRZ5Q77diIUIN6xHAk/n/vnasumner/b/apex-docker-files/o/linuxx64_12201_database.zip

4. Get Oracle Application Express (APEX) Software.

  1. Open in your browser http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html.
  2. Review and accept the terms and conditions.
  3. Click on the Download link right next to where it says Oracle Application Express 5.1.4 - All languages.
  4. Upload the file apex_5.1.4.zip to your Virtual Machine.

NOTE: We know that the network might be sometimes slow so we temporary have made available the software via a public link and you can wget it directly from your VM. πŸ˜„

wget https://objectstorage.us-ashburn-1.oraclecloud.com/p/cltQhKsnYcTF-Zkb3iSTbD3xHhIF8YTgQPD0Odax06c/n/vnasumner/b/apex-docker-files/o/apex_5.1.4.zip

5. Get Oracle REST Data Services (ORDS) Software.

  1. Open in your browser http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html.
  2. Review and accept the terms and conditions.
  3. Locate version Oracle REST Data Services 18.1.1
  4. Click on the Download link right next to where it says Oracle REST Data Services (8269e56d278f9bb87733a58d754a6f62).
  5. Upload the file ords.18.1.1.95.1251.zip to your Virtual Machine.

NOTE: We know that the network might be sometimes slow so we temporary have made available the software via a public link and you can wget it directly from your VM. πŸ˜„

wget https://objectstorage.us-ashburn-1.oraclecloud.com/p/TPtEJ4hKDK9DqHTKnZYbAtJEYlMev28x6izNnDWUHMY/n/vnasumner/b/apex-docker-files/o/ords.18.1.1.95.1251.zip

6. Get Base Oracle Database Docker Image Files.

  1. Clone Oracle's docker repo

    $ git clone https://github.com/oracle/docker-images.git
    

7. Get APEX Docker Image Files

  1. Clone a copy of our great repo πŸ™ƒ.

    $ git clone https://github.com/viscosityna/docker-apex.git
    
  2. Create a directory that will help us install APEX auto-magically πŸ˜‰.

    $ mkdir -p docker-apex/patches/apex
    

8. Get ORDS Docker Image Files.

  1. Clone a copy of our great repo πŸ™ƒ.

    $ git clone https://github.com/viscosityna/docker-ords.git
    

9.Lets Build the Image

We will be building an image of Oracle Database version 12.2.0.1

  1. Move the database software into the directory docker-images/OracleDatabase/SingleInstance/dockerfiles/

    $ mv linuxx64_12201_database.zip docker-images/OracleDatabase/SingleInstance/dockerfiles/12.2.0.1/
    
  2. Let's build the base image.

    Grab a cup of coffe this will take a few minutes β˜•οΈ.

    $ cd docker-images/OracleDatabase/SingleInstance/dockerfiles/
    $ ./buildDockerImage.sh -v 12.2.0.1 -s
    

    Once the build process is successful you should see a message as below:

    ... 
    Successfully built <Image ID> 
    Successfully tagged oracle/database:12.2.0.1-se2 
    ...
    
  3. Lets go back to our home directory.

    $ cd ~
    
  4. Copy APEX software into the directory docker-apex/patches/apex/.

    $ cp apex_5.1.4.zip docker-apex/patches/apex/
    
  5. Let's build the APEX image.

    $ cd docker-apex/
    $ docker build \
      --build-arg oracle_db_version=12.2.0.1 \
      --build-arg oracle_db_edition=se2 \
      -t apex-db:latest .
    

    Once the build process is successful you should see a message as below:

    ...
    Successfully built <Image ID>
    Successfully tagged apex-db:latest
    ...
    
  6. Lets go back to our home director, once again πŸ˜‰.

    $ cd ~
    
  7. Move ORDS software into the directory docker-ords/.

    $ mv ords.18.1.1.95.1251.zip docker-ords/
    
  8. Let's build the ORDS image.

    $ cd docker-ords/
    $ docker build \
      --build-arg tomcat_version=7.0.82 \
      --build-arg jre_version=jre8 \
      --build-arg ords_install_pkg=ords.18.1.1.95.1251.zip \
      -t ords:latest . 
    

    Once the build process is successful you should see a message as below:

    ...
    Successfully built <Image ID>
    Successfully tagged ords:latest
    ...
    

10. Let's Run APEX!.

  1. Let's go to our home directory once again, it's the last time we promise πŸ™ƒ.

    cd ~
    
  2. Create a docker network so the APEX container and the ORDS container can find each other ❀️.

    $ docker network create net01
    

    Once the crate network successful you should see a message as below:

    <Network ID>
    
  3. Start a docker container for APEX.

    $ docker run -d \
      --network=net01 \
      --name=apex \
      -e ORACLE_PWD=super_secret \
      -p 1521:1521 \
      -p 5500:5500 \
      -v /home/ubuntu/docker-apex/patches:/opt/oracle/patches \
      apex-db:latest
    

    Once the run container command is successful you should see a message as below:

    <Container ID>
    

    Below you can find a brief explanation of each parameter passed to docker run

    Parameter Description
    -d Indicates the command docker run to run in "deatached" mode, so it won't take over the command line prompt.
    --network Indicates into which docker network we want the container to run.
    --name The name of the container, we can use this name in any docker command to interact with it.
    -e ORACLE_PWD= This let's us set an environment variable in the container before the startup routine starts. This is how we pass in the password we want for all Oracle users (SYSTEM, SYS, APEX_PUBLIC_USER, APEX_LISTENER, APEX_REST_PUBLIC_USER). You can set it to anything you want, just make note of it because you will need this when running our ords container.
    -p Lets us map a port inside the container to a port in our host VM
    -v Lets us mount a path in our host VM into a volume in our container. You ONLY can mount volumes that are exposed in the docker image.
    apex-db:latest This is the name of the image we built.
  4. Now let's monitor the container startup routine.

    $ docker logs -f apex
    

    Take a water break this will take a few minutes.

    Once the container startup routine is successful you should see a message as below, at this point you can hit Ctrl+C to cancel the docker logs -f command:

    ...
    
    #########################
    DATABASE IS READY TO USE!
    #########################
    ... 
    
  5. Unzip APEX software, we'll use this to reference the static files from our ORDS container.

    $ unzip apex_5.1.4.zip
    $ mv apex apex-5.1.4
    
  6. Start a docker container for ORDS.

    $ docker run -d \
      --network=net01 \
      --name=ords \
      -p 8080:8080 \
      -v /home/ubuntu/apex-5.1.4/images:/usr/local/tomcat/webapps/i \
      ords:latest \
      --db-host apex \
      --db-port 1521  \
      --db-service-name ORCLPDB1 \
      --apex-pu-pass super_secret \
      --apex-rest-pu-pass super_secret \
      --apex-listener-pass super_secret 
    

    Once the run container command is successful you should see a message as below:

    <Container ID>
    

    Below you can find a brief explanation of each parameter passed to docker run:

    Parameter Description
    -d Indicates the command docker run to run in "deatached" mode, so it won't take over the command line prompt.
    --network Indicates into which docker network we want the container to run.
    --name The name of the container, we can use this name in any docker command to interact with it.
    -p Lets us map a port inside the container to a port in our host VM
    -v Lets us mount a path in our host VM into a volume in our container. You ONLY can mount volumes that are exposed in the docker image.
    ords:latest This is the name of the image we built.
    --db-host This is how we pass configuration to ORDS for the database's host. Since both our containers are running in the same docker network we can reference internally for them by the container name πŸ˜„.
    --db-port The port we mapped to our host VM for the apex container's 1521 port, most likely is 1521.
    --db-service-name The service name for our database, for our workshop it will be always ORCLPDB1.
    --apex-pu-pass The password of the APEX_PUBLIC_USER database username, use the password provided when running the apex container in the parameter -e ORACLE_PWD=<password> most likely it would be super_secret if you didn't change the command in this guide.
    --apex-rest-pu-pass The password for the APEX_REST_PULIC_USER database username, use the password provided when running the apex container in the parameter -e ORACLE_PWD=<password> most likely it would be super_secret if you didn't change the command in this guide.
    --apex-listener-pass The password for the APEX_LISTENER database username, use the password provided when running the apex container in the parameter -e ORACLE_PWD=<password> most likely it would be super_secret if you didn't change the command in this guide.
  7. Now let's monitor the container startup routine.

    $ docker logs -f ords 
    

    Once the container startup routine is successful you should see a message as below, at this point you can hit Ctrl+C to cancel the docker logs -f command:

    ...
    
    INFO: Server startup in <STARTUP TIME> ms
    
    ... 
    
  8. APEX is strict for his INTERNAL workspace ADMIN user's password, so we will have to do this one manually .... for now πŸ˜„.

    On this step we will connect into the apex container via sqlplus and will invoke the execution of a .sql command that resides in a path also in the container.

    NOTE: Make sure you provide a password that at least has one UPPERCASE letter and one NUMBER and one special character for the Admin's Password prompt.

    $ docker exec -it apex sqlplus sys/super_secret@orclpdb1 as sysdba
    

    Go through the prompts and provide values, when done providing information you can hit Ctrl+D or type in quit to exit the sqlplus session in the container and get back to your host terminal.

    
    SQL*Plus: Release 12.2.0.1.0 Production on Thu Apr 12 13:24:32 2018
    
    Copyright (c) 1982, 2016, Oracle.  All rights reserved.
    
    
     Connected to:
     Oracle Database 12c Standard Edition Release 12.2.0.1.0 - 64bit Production
    
     SQL> @/opt/oracle/scripts/setup/apex/apxchpwd.sql
     ================================================================================
     This script can be used to change the password of an Application Express
     instance administrator. If the user does not yet exist, a user record will be
     created.
     ================================================================================
     Enter the administrator's username [ADMIN]
     User "ADMIN" does not yet exist and will be created.
     Enter ADMIN's email [ADMIN] [email protected]
     Enter ADMIN's password []
     Created instance administrator ADMIN.
    
     SQL>
    

You are all set!!

Open your browser and go to <Virtual Machine Public IP>:8080/ords

Use the follow information to login into the APEX Instance Admin Console and create your first APEX workspace.

Field Value
WORKSPACE INTERNAL
USER ADMIN
PASSWORD Your super secure password.