Skip to content

Commit b1ae912

Browse files
gvenzlDjelibeybi
authored andcommitted
Adding Oracle REST Data Services Docker image (#541)
* Provide ORDS Docker image
1 parent b371769 commit b1ae912

File tree

12 files changed

+444
-0
lines changed

12 files changed

+444
-0
lines changed

OracleRestDataServices/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

OracleRestDataServices/COPYRIGHT

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 1982 - 2017, Oracle Corporation. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

OracleRestDataServices/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this
6+
software, associated documentation and/or data (collectively the "Software"), free of charge and under any and
7+
all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor
8+
hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or
9+
(ii) the Larger Works (as defined below), to deal in both
10+
11+
(a) the Software, and
12+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software
13+
(each a “Larger Work” to which the Software is contributed by such licensors),
14+
15+
without restriction, including without limitation the rights to copy, create derivative works of, display,
16+
perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have
17+
sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms.
18+
19+
This license is subject to the following condition:
20+
The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must
21+
be included in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
24+
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27+
IN THE SOFTWARE.
28+

OracleRestDataServices/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Oracle REST Data Services on Docker
2+
Sample Docker build files to facilitate installation, configuration, and environment setup for DevOps users.
3+
For more information about Oracle REST Data Services (ORDS) please see the [ORDS Documentation](http://www.oracle.com/technetwork/developer-tools/rest-data-services/documentation/index.html).
4+
5+
## How to build and run
6+
This project offers sample Dockerfiles for Oracle REST Data Services
7+
8+
To assist in building the images, you can use the [buildDockerImage.sh](dockerfiles/buildDockerImage.sh) script. See below for instructions and usage.
9+
10+
The `buildDockerImage.sh` script is just a utility shell script that performs MD5 checks and is an easy way for beginners to get started. Expert users are welcome to directly call `docker build` with their prefered set of parameters.
11+
12+
### Building Oracle REST Data Services Install Images
13+
**IMPORTANT:** You will have to provide the installation binaries of ORDS and put them into the `dockerfiles` folder. You only need to provide the binaries for the version you are going to install. The binaries can be downloaded from the [Oracle Technology Network](http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html). Note that you must not uncompress the binaries. The script will handle that for you and fail if you uncompress them manually!
14+
15+
The image builds on top of the `oracle/serverjre:8` image which is also provided in this repository, see [OracleJava](../OracleJava). You will first have to build the `oracle/serverjre:8` image before you can build this image!
16+
17+
Before you build the image make sure that you have provided the installation binaries and put them into the right folder. Once you have done that go into the **dockerfiles** folder and run the **buildDockerImage.sh** script:
18+
19+
[oracle@localhost dockerfiles]$ ./buildDockerImage.sh -h
20+
21+
Usage: buildDockerImage.sh [-i] [-o] [Docker build option]
22+
Builds a Docker Image for Oracle Rest Data Services
23+
24+
Parameters:
25+
-i: ignores the MD5 checksums
26+
-o: passes on Docker build option
27+
28+
LICENSE UPL 1.0
29+
30+
Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
31+
32+
**IMPORTANT:** The resulting images will be an image with the ORDS binaries installed. On first startup of the container ORDS will be setup.
33+
34+
### Running Oracle REST Data Services in a Docker container
35+
36+
Before you run your ORDS Docker container you will have to specify a network in wich ORDS will communicate with the database you would like it to expose via REST.
37+
In order to do so you need to create a [user-defined network](https://docs.docker.com/engine/userguide/networking/#user-defined-networks) first.
38+
This can be done via following command:
39+
40+
docker network create <your network name>
41+
42+
Once you have created the network you can double check by running:
43+
44+
docker network ls
45+
46+
You should see your network, amongst others, in the output.
47+
48+
As a next step you will have to start your database container with the specified network. This can be done via the `docker run` `--network` option, for example:
49+
50+
docker run --name oracledb --network=<your network name> oracle/database:12.2.0.1-ee
51+
52+
The database container will be visible within the network by its name passed on with the `--name` option, in the example above **oracledb**.
53+
Once your database container is up and running and the database available, you can run a new ORDS container.
54+
55+
To run your ORDS Docker image use the **docker run** command as follows:
56+
57+
docker run --name <container name> \
58+
--network=<name of your created network> \
59+
-p <host port>:8888 \
60+
-e ORACLE_HOST=<Your Oracle DB host (default: localhost)> \
61+
-e ORACLE_PORT=<Your Oracle DB port (default: 1521)> \
62+
-e ORACLE_SERVICE=<your Oracle DB Service name (default: ORCLPDB1)> \
63+
-e ORACLE_PWD=<your database SYS password> \
64+
-e ORDS_PWD=<your ORDS password> \
65+
-v [<host mount point>:]/opt/oracle/ords/config/ords
66+
oracle/restdataservices:3.0.10
67+
68+
Parameters:
69+
--name: The name of the container (default: auto generated)
70+
--network: The network to use to communicate with databases.
71+
-p: The port mapping of the host port to the container port.
72+
One port is exposed: 8888
73+
-e ORACLE_HOST: The Oracle Database hostname that ORDS should use (default: localhost)
74+
This should be the name that you gave your Oracle database Docker container, e.g. "oracledb"
75+
-e ORACLE_PORT: The Oracle Database port that ORSD should use (default: 1521)
76+
-e ORACLE_SERVICE: The Oracle Database Service name that ORDS should use (default: ORCLPDB1)
77+
-e ORACLE_PWD: The Oracle Database SYS password
78+
-e ORDS_PWD: The ORDS_PUBLIC_USER password
79+
-v /opt/oracle/ords/config/ords
80+
The data volume to use for the ORDS configuration files.
81+
Has to be writable by the Unix "oracle" (uid: 54321) user inside the container!
82+
If omitted the ORDS configuration files will not be persisted over container recreation.
83+
84+
Once the container has been started and ORDS configured you can send REST calls to ORDS.
85+
86+
## Known issues
87+
None
88+
89+
## Support
90+
91+
## License
92+
To download and run ORDS, regardless whether inside or outside a Docker container, you must download the binaries from the Oracle website and accept the license indicated at that page.
93+
94+
All scripts and files hosted in this project and GitHub [docker-images/OracleRestDataServices](./) repository required to build the Docker images are, unless otherwise noted, released under the Universal Permissive License (UPL), Version 1.0.
95+
96+
## Copyright
97+
Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3da5d0476bc95662623bc1ddbb2dad98 ords.3.0.10.165.06.53.zip
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4d572ae9f12b9636209d73d8d74ad2c6 ords.3.0.11.180.12.34.zip
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
e106a17ece9eb92dedb83e88ed44b01f ords.3.0.12.263.15.32.zip
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# LICENSE UPL 1.0
2+
#
3+
# Copyright (c) 1982-2017 Oracle and/or its affiliates. All rights reserved.
4+
#
5+
# ORACLE DOCKERFILES PROJECT
6+
# --------------------------
7+
# This is the Dockerfile for Oracle Rest Data Services
8+
#
9+
# REQUIRED FILES TO BUILD THIS IMAGE
10+
# ----------------------------------
11+
# (1) ords.3.0.10.165.06.53.zip
12+
# Download Oracle Rest Data Services from
13+
# http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html
14+
#
15+
# HOW TO BUILD THIS IMAGE
16+
# -----------------------
17+
# Put the downloaded file in the same directory as this Dockerfile
18+
# Run:
19+
# $ docker build -t oracle/restdataservices:3.0.10 .
20+
#
21+
# Pull base image
22+
# ---------------
23+
FROM oracle/serverjre:8
24+
25+
# Labels
26+
# ----------
27+
LABEL maintainer "gerald.venzl@oracle.com"
28+
29+
# Environment variables required for this build (do NOT change)
30+
# -------------------------------------------------------------
31+
ENV ORDS_HOME=/opt/oracle/ords \
32+
INSTALL_FILE=ords*.zip \
33+
CONFIG_PROPS="ords_params.properties.tmpl" \
34+
STANDALONE_PROPS="standalone.properties.tmpl" \
35+
RUN_FILE="runOrds.sh"
36+
37+
# Copy binaries
38+
# -------------
39+
COPY $INSTALL_FILE $CONFIG_PROPS $STANDALONE_PROPS $RUN_FILE $ORDS_HOME/
40+
41+
# Setup filesystem and oracle user
42+
# Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with ORDS installation
43+
# ------------------------------------------------------------
44+
RUN mkdir -p $ORDS_HOME/doc_root && \
45+
chmod ug+x $ORDS_HOME/*.sh && \
46+
groupadd dba && \
47+
useradd -d /home/oracle -g dba -m -s /bin/bash oracle && \
48+
cd $ORDS_HOME && \
49+
jar -xf $INSTALL_FILE && \
50+
rm $INSTALL_FILE && \
51+
mkdir -p $ORDS_HOME/config/ords && \
52+
java -jar $ORDS_HOME/ords.war configdir $ORDS_HOME/config && \
53+
chown -R oracle:dba $ORDS_HOME
54+
55+
# Finalize setup
56+
# -------------------
57+
USER oracle
58+
WORKDIR /home/oracle
59+
60+
VOLUME ["$ORDS_HOME/config/ords"]
61+
EXPOSE 8888
62+
63+
# Define default command to start Oracle Database.
64+
CMD $ORDS_HOME/$RUN_FILE
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/bin/bash
2+
#
3+
# Since: February, 2017
4+
# Author: gerald.venzl@oracle.com
5+
# Description: Build script for building Oracle Rest Data Services Docker images.
6+
#
7+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8+
#
9+
# Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
10+
#
11+
12+
usage() {
13+
cat << EOF
14+
15+
Usage: buildDockerImage.sh [-i] [-o] [Docker build option]
16+
Builds a Docker Image for Oracle Rest Data Services
17+
18+
Parameters:
19+
-i: ignores the MD5 checksums
20+
-o: passes on Docker build option
21+
22+
LICENSE UPL 1.0
23+
24+
Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
25+
26+
EOF
27+
exit 0
28+
}
29+
30+
# Validate packages
31+
checksumPackages() {
32+
echo "Checking if required packages are present and valid..."
33+
md5sum -c Checksum.$VERSION
34+
if [ "$?" -ne 0 ]; then
35+
echo "MD5 for required packages to build this image did not match!"
36+
echo "Make sure to download missing files in folder '$VERSION'."
37+
exit $?
38+
fi
39+
}
40+
41+
# Parameters
42+
VERSION=""
43+
SKIPMD5=0
44+
DOCKEROPS=""
45+
46+
while getopts "hio:" optname; do
47+
case "$optname" in
48+
"h")
49+
usage
50+
;;
51+
"i")
52+
SKIPMD5=1
53+
;;
54+
"o")
55+
DOCKEROPS="$OPTARG"
56+
;;
57+
"?")
58+
usage;
59+
exit 1;
60+
;;
61+
*)
62+
# Should not occur
63+
echo "Unknown error while processing options inside buildDockerImage.sh"
64+
;;
65+
esac
66+
done
67+
68+
# Determine latest version
69+
# Do this after the options so that users can still do a "-h"
70+
if [ `ls -al ords*zip 2>/dev/null | wc -l` -gt 1 ]; then
71+
echo "ERROR: Found multiple versions of ORDS zip files.";
72+
echo "ERROR: Please only put one ORDS zip file into this directory!";
73+
exit 1;
74+
else
75+
VERSION=$(ls ords*zip 2>/dev/null | awk 'match ($0, /(ords\.)(.{1,2}\..{1,2}\..{1,2})\.(.+.zip)/, result) { print result[2] }')
76+
fi;
77+
78+
if [ -z "$VERSION" ]; then
79+
echo "ERROR: No install file is in this directory!"
80+
echo "ERROR: Please copy the install file into this directory or refer to the ReadMe!"
81+
exit 1;
82+
fi;
83+
84+
85+
# Oracle Database Image Name
86+
IMAGE_NAME="oracle/restdataservices:$VERSION"
87+
88+
if [ ! "$SKIPMD5" -eq 1 ]; then
89+
checksumPackages
90+
else
91+
echo "Ignored MD5 checksum."
92+
fi
93+
94+
echo "=========================="
95+
echo "DOCKER info:"
96+
docker info
97+
echo "=========================="
98+
99+
# Proxy settings
100+
PROXY_SETTINGS=""
101+
if [ "${http_proxy}" != "" ]; then
102+
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg http_proxy=${http_proxy}"
103+
fi
104+
105+
if [ "${https_proxy}" != "" ]; then
106+
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg https_proxy=${https_proxy}"
107+
fi
108+
109+
if [ "${ftp_proxy}" != "" ]; then
110+
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg ftp_proxy=${ftp_proxy}"
111+
fi
112+
113+
if [ "${no_proxy}" != "" ]; then
114+
PROXY_SETTINGS="$PROXY_SETTINGS --build-arg no_proxy=${no_proxy}"
115+
fi
116+
117+
if [ "$PROXY_SETTINGS" != "" ]; then
118+
echo "Proxy settings were found and will be used during build."
119+
fi
120+
121+
# ################## #
122+
# BUILDING THE IMAGE #
123+
# ################## #
124+
echo "Building image '$IMAGE_NAME' ..."
125+
126+
# BUILD THE IMAGE (replace all environment variables)
127+
BUILD_START=$(date '+%s')
128+
docker build --force-rm=true --no-cache=true $DOCKEROPS $PROXY_SETTINGS \
129+
-t $IMAGE_NAME -f Dockerfile . || {
130+
echo "There was an error building the image."
131+
exit 1
132+
}
133+
BUILD_END=$(date '+%s')
134+
BUILD_ELAPSED=`expr $BUILD_END - $BUILD_START`
135+
136+
echo ""
137+
138+
if [ $? -eq 0 ]; then
139+
cat << EOF
140+
Oracle Rest Data Services version $VERSION is ready to be extended:
141+
142+
--> $IMAGE_NAME
143+
144+
Build completed in $BUILD_ELAPSED seconds.
145+
146+
EOF
147+
148+
else
149+
echo "Oracle Rest Data Services Docker Image was NOT successfully created. Check the output and correct any reported problems with the docker build operation."
150+
fi
151+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
rest.services.ords.add=true
2+
db.hostname=###ORACLE_HOST###
3+
db.port=###ORACLE_PORT###
4+
db.servicename=###ORACLE_SERVICE###
5+
plsql.gateway.add=false
6+
rest.services.apex.add=false
7+
rest.services.ords.add=true
8+
standalone.http.port=8888
9+
standalone.mode=false
10+
standalone.use.https=true
11+
sys.user=SYS
12+
sys.password=###ORACLE_PWD###
13+
user.public.password=###ORDS_PWD###
14+

0 commit comments

Comments
 (0)