├── Dockerfile ├── LICENSE ├── README.md ├── build ├── ords_params.properties ├── runOrds.sh ├── setupOrds.sh └── standalone.properties /Dockerfile: -------------------------------------------------------------------------------- 1 | # REQUIRED FILES TO BUILD THIS IMAGE 2 | # ---------------------------------- 3 | # (1) ords.*.zip 4 | # Download Oracle Rest Data Services from 5 | # http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html 6 | # 7 | # OPTIONS FILES TO BUILD THIS IMAGE 8 | # ---------------------------------- 9 | # (1) sqlcl.*.zip 10 | # Download SQLcl from 11 | # http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html 12 | # 13 | # (2) apex*.zip 14 | # Download SQLcl from 15 | # http://www.oracle.com/technetwork/developer-tools/apex/downloads/download-085147.html 16 | # 17 | # HOW TO BUILD THIS IMAGE 18 | # ----------------------- 19 | # Put the downloaded file in the same directory as this Dockerfile 20 | # 21 | # 22 | # To Build: 23 | # Edit and Run: 24 | # $ docker build -t krisrice/ords:3.0.10 --build-arg DBHOST=192.168.3.119 --build-arg DBSERVICE=orcl --build-arg DBPORT=1521 --build-arg DBPASSWD=oracle . 25 | # To Run: 26 | # $ docker run -p 8888:8888 -p 8443:8443 -it krisrice/ords:3.0.10 27 | # 28 | # To Run with existing apex/images 29 | # 30 | # $ docker run -p 8888:8888 -p 8443:8443 -v /Users/klrice/workspace/apex_trunk/images/:/opt/oracle/ords/doc_root/i -it krisrice/ords:3.0.10 31 | # 32 | # Pull base image 33 | # --------------- 34 | FROM openjdk:8 35 | 36 | ARG DBHOST 37 | ARG DBPORT 38 | ARG DBPASSWD 39 | ARG DBSERVICE 40 | 41 | # Maintainer 42 | # ---------- 43 | MAINTAINER Kris Rice 44 | 45 | # Environment variables required for this build (do NOT change) 46 | # ------------------------------------------------------------- 47 | ENV ORACLE_BASE=/opt/oracle \ 48 | ORDS_HOME=/opt/oracle/ords \ 49 | INSTALL_FILE="ords.*.zip" \ 50 | SQLCL_FILE="sqlcl*.zip" \ 51 | APEX_HOME=/opt/oracle/apex \ 52 | APEX_FILE="apex*.zip" \ 53 | CONFIG_PROPS="ords_params.properties" \ 54 | STANDALONE_PROPS="standalone.properties" \ 55 | RUN_FILE="runOrds.sh" \ 56 | CONFIG_FILE="setupOrds.sh" 57 | 58 | # Copy binaries 59 | # ------------- 60 | COPY $INSTALL_FILE $SQLCL_FILE $CONFIG_PROPS $RUN_FILE $CONFIG_FILE $STANDALONE_PROPS $ORDS_HOME/ 61 | COPY $SQLCL_FILE $ORACLE_BASE/ 62 | COPY $APEX_FILE $ORACLE_BASE/ 63 | 64 | # Setup filesystem and oracle user 65 | # Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with ORDS installation 66 | # ------------------------------------------------------------ 67 | RUN mkdir -p $ORDS_HOME/config && \ 68 | chmod ug+x $ORDS_HOME/$CONFIG_FILE $ORDS_HOME/$RUN_FILE && \ 69 | groupadd -g 500 dba && \ 70 | useradd -d /home/oracle -g dba -m -s /bin/bash oracle && \ 71 | echo oracle:oracle | chpasswd && \ 72 | if [ -f $ORACLE_BASE/$SQLCL_FILE ]; then cd $ORACLE_BASE && jar -xf $ORACLE_BASE/$SQLCL_FILE && chmod 755 $ORACLE_BASE/sqlcl/bin/sql; rm $ORACLE_BASE/$SQLCL_FILE; fi && \ 73 | if [ -f $ORACLE_BASE/$APEX_FILE ]; then cd $ORACLE_BASE && jar -xf $ORACLE_BASE/$APEX_FILE; rm $ORACLE_BASE/$APEX_FILE; fi && \ 74 | cd $ORDS_HOME && \ 75 | jar -xf $INSTALL_FILE && \ 76 | rm $INSTALL_FILE && \ 77 | $ORDS_HOME/$CONFIG_FILE && \ 78 | chown -R oracle:dba $ORACLE_BASE 79 | 80 | 81 | # Start installation 82 | # ------------------- 83 | ENV PATH="${PATH}:$ORACLE_BASE/sqlcl/bin" 84 | 85 | USER oracle 86 | 87 | WORKDIR /home/oracle 88 | 89 | EXPOSE 8888 90 | 91 | VOLUME $ORDS_HOME/config 92 | 93 | # Define default command to start Oracle Database. 94 | CMD $ORDS_HOME/$RUN_FILE 95 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kris Rice 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-ords-sqlcl-apex 2 | Build scripts to make a docker image with Oracle REST Data Services, Oracle SQLcl, and Oracle Application Express 3 | 4 | 5 | # Prerequisites 6 | 7 | Download from OTN ORDS 8 | 9 | 10 | Required: [Download ORDS](http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html) 11 | 12 | Required SQLcl: [Download SQLcl](http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html) 13 | 14 | Optional APEX: [Download APEX](http://www.oracle.com/technetwork/developer-tools/apex/downloads/download-085147.html) 15 | 16 | 17 | 18 | # Build Process 19 | 20 | The docker build is parameterized to allow the database to reside anywhere. 21 | Build Parameters 22 | 23 | DBHOST : IP Address of the database host 24 | DBSERVICE : DB Service name to connect 25 | DBPORT : DB Port to connect 26 | DBPASSWD : SYS password 27 | 28 | Optional 29 | 30 | PORT : HTTP Port for ORDS (Default: 8888) 31 | SPORT : HTTPS Port for ORDS (Default: 8443) 32 | APEXI : path to the apex images folder INSIDE the doc 33 | 34 | 35 | # Example Build 36 | ``` 37 | docker build -t krisrice/ords:3.0.10 \ 38 | --build-arg DBHOST=192.168.3.119 \ 39 | --build-arg DBSERVICE=orcl \ 40 | --build-arg DBPORT=1521 \ 41 | --build-arg DBPASSWD=oracle . 42 | ``` 43 | 44 | # Run the docker 45 | 46 | Once the image is built, use docker run. Being sure to port forward the ports specified to be accesible. 47 | 48 | In this case, the default, Forward 8888 and 8433 49 | 50 | 51 | ``` 52 | docker run -p 8888:8888 -p 8443:8443 -it krisrice/ords:3.0.10 53 | 54 | ``` 55 | ## Run in the Background 56 | 57 | ``` 58 | docker run -d -p 8888:8888 -p 8443:8443 --name=ords krisrice/ords:3.0.10 59 | 60 | ``` 61 | ## Logs from background 62 | 63 | 64 | ``` 65 | docker logs -f ords 66 | ``` 67 | 68 | ## Docker image layout and env 69 | 70 | All the software is installed in the image in /opt/oracle 71 | ``` 72 | $ ls -ltr 73 | drwxr-xr-x 4 oracle dba 4096 May 31 19:58 sqlcl 74 | drwxr-xr-x 6 oracle dba 4096 May 31 19:58 apex 75 | drwxr-xr-x 1 oracle dba 4096 May 31 19:58 ords 76 | 77 | ``` 78 | 79 | ## Bash Env variables 80 | 81 | SQLcl is added to the PATH 82 | 83 | There are some variables in the env for reference use 84 | 85 | ``` 86 | $ env | sort 87 | APEX_FILE=apex*.zip 88 | APEX_HOME=/opt/oracle/apex 89 | CONFIG_FILE=setupOrds.sh 90 | CONFIG_PROPS=ords_params.properties 91 | INSTALL_FILE=ords.*.zip 92 | ORACLE_BASE=/opt/oracle 93 | ORDS_HOME=/opt/oracle/ords 94 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/oracle/sqlcl/bin 95 | RUN_FILE=runOrds.sh 96 | SQLCL_FILE=sqlcl*.zip 97 | STANDALONE_PROPS=standalone.properties 98 | ``` 99 | 100 | 101 | ## Serve files in the DOC ROOT from the host 102 | 103 | Using the -v command docker can map a filesystem from the host into the image. This would allow for serving host files as part of the ORDS docroot 104 | ``` 105 | docker run -p 8888:8888 -p 8443:8443 -v /Users/klrice/workspace/apex_trunk/images/:/opt/oracle/ords/doc_root/i -it krisrice/ords:3.0.10 106 | 107 | ``` 108 | -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | # 2 | # example build 3 | # 4 | docker rmi -f krisrice/ords:3.0.10 5 | 6 | docker build -t krisrice/ords:3.0.10 --build-arg DBHOST=192.168.3.119 --build-arg DBSERVICE=orcl --build-arg DBPORT=1521 --build-arg DBPASSWD=oracle . 7 | 8 | docker run -p 8888:8888 -p 8443:8443 -v /Users/klrice/workspace/apex_trunk/images/:/opt/oracle/ords/doc_root/i -it krisrice/ords:3.0.10 9 | -------------------------------------------------------------------------------- /ords_params.properties: -------------------------------------------------------------------------------- 1 | db.hostname=###DBHOST### 2 | db.port=###DBPORT### 3 | db.servicename=###DBSERVICE### 4 | sys.user=SYS 5 | sys.password=###DBPASSWD### 6 | db.username=apex_public_user 7 | db.password=###RANDOMPASSWD### 8 | plsql.gateway.add=true 9 | migrate.apex.rest=false 10 | rest.services.apex.add=true 11 | rest.services.ords.add=true 12 | standalone.http.port=###PORT### 13 | standalone.mode=false 14 | standalone.use.https=true 15 | user.public.password=oracle 16 | user.apex.listener.password=###RANDOMPASSWD### 17 | user.apex.restpublic.password=###RANDOMPASSWD### 18 | user.public.password=###RANDOMPASSWD### 19 | -------------------------------------------------------------------------------- /runOrds.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | 4 | function startOrds() { 5 | java -jar $ORDS_HOME/ords.war standalone 6 | } 7 | 8 | 9 | ########### SIGTERM handler ############ 10 | function _term() { 11 | echo "Stopping container." 12 | echo "SIGTERM received, shutting down ORDS!" 13 | pkill ords; 14 | } 15 | 16 | ########### SIGKILL handler ############ 17 | function _kill() { 18 | echo "SIGKILL received, shutting down ORDS!" 19 | pkill -9 ords; 20 | } 21 | 22 | ############# MAIN ################ 23 | 24 | # Set SIGTERM handler 25 | trap _term SIGTERM 26 | 27 | # Set SIGKILL handler 28 | trap _kill SIGKILL 29 | 30 | # Check whether ords is already setup 31 | startOrds; 32 | 33 | echo "#####################" 34 | echo "ORDS IS READY TO USE!" 35 | echo "#####################" 36 | 37 | 38 | childPID=$! 39 | wait $childPID 40 | -------------------------------------------------------------------------------- /setupOrds.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # simple function to replace strings in param files 4 | function replace(){ 5 | FROM=$1 6 | TO=$2 7 | IN=$3 8 | sed -i -e "s|###${FROM}###|${TO}|g" $IN 9 | } 10 | 11 | function setupAPEX(){ 12 | if [ -f $APEX_HOME/apexins.sql ]; then 13 | echo "#####################" 14 | echo "INSTALLING APEX..." 15 | echo "#####################" 16 | 17 | # setup apex images for the ords install 18 | APEXI=$APEX_HOME/images 19 | 20 | cd $APEX_HOME 21 | # setting passwords to abc xyz since setupORDS scrambles them 22 | /opt/oracle/sqlcl/bin/sql /nolog <