Skip to content

Commit 7926306

Browse files
committed
Support majority of DB version and editions.
1 parent b56cd59 commit 7926306

File tree

9 files changed

+129
-65
lines changed

9 files changed

+129
-65
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ $RECYCLE.BIN/
8484
# End of https://www.gitignore.io/api/osx,macos,linux,windows
8585
*.zip
8686
*.rpm
87+
*.tar
88+
*.gz
8789
tmp
8890
dockerfiles
8991
oradata
90-
!sample.env
9192
*.env

01-build.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
ENV_FILE=${1:-.env}
4+
5+
. $ENV_FILE
6+
7+
BASE_DIR=$(pwd -P)
8+
DB_VERSION=${DB_VERSION:-18.4.0}
9+
DB_EDITION=$(echo ${DB_EDITION:-xe} | tr '[:upper:]' '[:lower:]')
10+
11+
case "$DB_EDITION" in
12+
"ee")
13+
DB_EDITION_FLAG=-e
14+
;;
15+
"se2")
16+
DB_EDITION_FLAG=-s
17+
;;
18+
*)
19+
DB_EDITION_FLAG=-x
20+
;;
21+
esac
22+
23+
if [ -d 'dockerfiles' ]; then
24+
rm -rf dockerfiles;
25+
fi
26+
27+
echo "##### Grabbing official Docker images from Oracle #####"
28+
git clone https://github.com/oracle/docker-images.git tmp
29+
30+
mv tmp/OracleDatabase/SingleInstance/dockerfiles/ .
31+
32+
rm -rf tmp/
33+
34+
echo "##### Staging RPM #####"
35+
if [ $DB_VERSION = '18.4.0' ] && [ $DB_EDITION = 'xe' ]; then
36+
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$BASE_DIR/files/oracle-database-xe-18c-1.0-1.x86_64.rpm
37+
DOCKER_FILE=Dockerfile.$DB_EDITION
38+
elif [ $DB_VERSION = '18.3.0' ]; then
39+
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$BASE_DIR/files/LINUX.X64_180000_db_home.zip
40+
DOCKER_FILE=Dockerfile
41+
elif [ $DB_VERSION = '12.2.0.1' ]; then
42+
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$BASE_DIR/files/linuxx64_12201_database.zip
43+
DOCKER_FILE=Dockerfile
44+
elif [ $DB_VERSION = '12.1.0.2' ]; then
45+
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$BASE_DIR/files/linuxamd64_12102_database_1of2.zip
46+
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$BASE_DIR/files/linuxamd64_12102_database_2of2.zip
47+
DOCKER_FILE=Dockerfile.$DB_EDITION
48+
else
49+
echo "Unknown or unsupported database version and/or edition."
50+
fi
51+
52+
cd $BASE_DIR
53+
54+
# echo "##### Modify target Dockerfile #####"
55+
# REPLACEMENT_STRING="COPY scripts/setup/ \$ORACLE_BASE/scripts/setup/\nCOPY scripts/startup/ \$ORACLE_BASE/scripts/startup/\nCOPY files/ /tmp/files/\n"
56+
# sed -i -r "s|^VOLUME.+$|${REPLACEMENT_STRING}|g" dockerfiles/${DB_VERSION}/${DOCKER_FILE:-Dockerfile}
57+
# mkdir -p dockerfiles/${DB_VERSION}/files
58+
# cp files/$INSTALL_FILE_APEX files/$INSTALL_FILE_ORDS files/$INSTALL_FILE_JAVA dockerfiles/${DB_VERSION}/files/
59+
# cp -R scripts dockerfiles/${DB_VERSION}/scripts
60+
61+
echo "##### Building Docker Image for Oracle Database ${DB_VERSION} ${DB_EDITION} #####"
62+
cd dockerfiles && . buildDockerImage.sh -v ${DB_VERSION} ${DB_EDITION_FLAG}
63+
64+
cd $BASE_DIR
65+
echo "##### Done #####"

01-stage.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

02-build.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

03-run.sh renamed to 02-run.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ ENV_FILE=${2:-.env}
55

66
. $ENV_FILE
77

8+
BASE_DIR=$(pwd -P)
9+
DB_VERSION=${DB_VERSION:-18.4.0}
10+
DB_EDITION=$(echo ${DB_EDITION:-xe} | tr '[:upper:]' '[:lower:]')
11+
812
echo "##### Removing any previous containers #####"
913
docker rm -vf $CONTAINER_NAME
1014

@@ -25,7 +29,7 @@ docker run -d --name $CONTAINER_NAME \
2529
-v $PWD/scripts/setup:/opt/oracle/scripts/setup \
2630
-v $PWD/scripts/startup:/opt/oracle/scripts/startup \
2731
-v $PWD/files:/tmp/files \
28-
oracle/database:18.4.0-xe
32+
oracle/database:${DB_VERSION}-${DB_EDITION}
2933

3034
echo "##### Tailing logs. Ctrl-C to exit. #####"
3135
docker logs -f $CONTAINER_NAME

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818

1919
1. Git clone this repository and set it as the working directory.
2020
2. Download the installer files:
21-
* [Oracle Database 18c XE](https://oracle.com/xe)
21+
* [Oracle Database 18c XE](https://oracle.com/xe) or any of the required installation files from [OTN](https://www.oracle.com/technetwork/database/)
2222
* [Oracle Application Express](https://apex.oracle.com/download) (the latest version is 19.1 as of March 29, 2019)
2323
* [Oracle REST Data Services](https://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html) (the latest version is 18.4 as of February 16, 2019)
24+
* [Java Development Kit SE 8](https://www.oracle.com/technetwork/java/javase/downloads/)
2425
3. Place all three files in the sub-directory `files`.
25-
4. Run the first script to grab the latest Docker [images](https://github.com/oracle/docker-images) from Oracle:
26-
```bash
27-
$ . 01-stage.sh
28-
```
29-
5. Create a new file that contains the required variables. The `sample.env` file is provided but should **not** be used directly. Make a copy, e.g. `mysettings.env`, and modify as desired. The file should contain the following variables:
26+
4. Create a new file that contains the required variables. Make a copy of `settings.env.sample`, e.g. `mysettings.env`, and modify as desired. The file should contain the following variables:
3027
```bash
3128
ORACLE_SID=XE
3229
ORACLE_PDB=XEPDB1
@@ -35,17 +32,18 @@
3532
APEX_ADMIN_PWD=Oracle__18
3633
INSTALL_FILE_APEX=apex_19.1.zip
3734
INSTALL_FILE_ORDS=ords-18.4.0.354.1002.zip
35+
INSTALL_FILE_JAVA=jdk-8u201-linux-x64.tar.gz
3836
DOCKER_ORDS_PORT=50080
3937
DOCKER_EM_PORT=55500
4038
DOCKER_DB_PORT=51521
4139
DB_VERSION=18.4.0
4240
DB_EDITION=XE
4341
```
44-
6. Run the second script to build the Oracle Database image, where the environment file is called `mysettings.env`:
42+
5. Run the first script to grab the latest Docker [images](https://github.com/oracle/docker-images) from Oracle and build the Oracle Database image. The script takes one parameter, the environment filename (`mysettings.env`):
4543
```bash
46-
$ . 02-build.sh mysettings.env
44+
$ . 01-build.sh mysettings.env
4745
```
48-
7. Run the final script to create and run the container, where the container name is `axer` (it is preferred that you execute a command using `sudo` before executing this script):
46+
6. Run the final script to create and run the container, where the container name is `axer` (it is preferred that you execute a command using `sudo` before executing this script):
4947
```bash
5048
$ . 03-run.sh axer mysettings.env
5149
```

scripts/setup/01-install.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
export APEX_HOME=$ORACLE_BASE/product/apex
44
export ORDS_HOME=$ORACLE_BASE/product/ords
5+
export JAVA_HOME=$ORACLE_BASE/product/java/latest
56
export SCRIPT_DIR=$SCRIPTS_ROOT
67
export FILES_DIR=/tmp/files
8+
export PATH=$JAVA_HOME/bin:$PATH
79

8-
echo "##### Install dependencies #####"
9-
yum install -y java-1.8.0-openjdk
10+
echo "##### Install dependencies if required #####"
11+
if [ ! -d $JAVA_HOME ]; then
12+
JAVA_DIR_NAME=`tar -tzf $FILES_DIR/$INSTALL_FILE_JAVA | head -1 | cut -f1 -d"/"`
13+
mkdir -p $ORACLE_BASE/product/java
14+
tar zxf $FILES_DIR/$INSTALL_FILE_JAVA --directory $ORACLE_BASE/product/java
15+
ln -s $ORACLE_BASE/product/java/$JAVA_DIR_NAME $JAVA_HOME
16+
fi
1017

1118
# Extract files
1219
echo "##### Extracting files ####"
@@ -28,8 +35,16 @@ esac
2835

2936
# Install APEX
3037
echo "##### Installing APEX #####"
31-
runuser oracle -m -s /bin/bash -c ". $SCRIPT_DIR/package/installApex.sh"
38+
if [ $UID = "0" ]; then
39+
runuser oracle -m -s /bin/bash -c ". $SCRIPT_DIR/package/installApex.sh"
40+
else
41+
. $SCRIPT_DIR/package/installApex.sh
42+
fi
3243

3344
# Install ORDS
3445
echo "##### Installing ORDS #####"
35-
runuser oracle -m -s /bin/bash -c ". $SCRIPT_DIR/package/installOrds.sh"
46+
if [ $UID = "0" ]; then
47+
runuser oracle -m -s /bin/bash -c ". $SCRIPT_DIR/package/installOrds.sh"
48+
else
49+
. $SCRIPT_DIR/package/installOrds.sh
50+
fi

scripts/startup/01-run.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
export APEX_HOME=$ORACLE_BASE/product/apex
44
export ORDS_HOME=$ORACLE_BASE/product/ords
5+
export JAVA_HOME=$ORACLE_BASE/product/java/latest
56
export SCRIPT_DIR=$SCRIPTS_ROOT
67
export FILES_DIR=/tmp/files
8+
export PATH=$JAVA_HOME/bin:$PATH
79

8-
echo "##### Install dependencies #####"
9-
yum install -y java-1.8.0-openjdk
10+
echo "##### Install dependencies if required #####"
11+
if [ ! -d $JAVA_HOME ]; then
12+
JAVA_DIR_NAME=`tar -tzf $FILES_DIR/$INSTALL_FILE_JAVA | head -1 | cut -f1 -d"/"`
13+
mkdir -p $ORACLE_BASE/product/java
14+
tar zxf $FILES_DIR/$INSTALL_FILE_JAVA --directory $ORACLE_BASE/product/java
15+
ln -s $ORACLE_BASE/product/java/$JAVA_DIR_NAME $JAVA_HOME
16+
fi
1017

1118
# Extract files
1219
echo "##### Extracting files if required ####"
@@ -26,4 +33,8 @@ fi
2633

2734
# Run ORDS
2835
echo "##### Starting ORDS #####"
29-
runuser oracle -m -s /bin/bash -c ". $SCRIPT_DIR/package/runOrds.sh"
36+
if [ $UID = "0" ]; then
37+
runuser oracle -m -s /bin/bash -c ". $SCRIPT_DIR/package/runOrds.sh"
38+
else
39+
. $SCRIPT_DIR/package/runOrds.sh
40+
fi

settings.env.sample

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ORACLE_SID=XE
2+
ORACLE_PDB=XEPDB1
3+
ORACLE_PWD=Oracle18
4+
APEX_ADMIN_EMAIL=myemail@domain.com
5+
APEX_ADMIN_PWD=Oracle__18
6+
APEX_PUBLIC_USER_PWD=Oracle18_1
7+
APEX_LISTENER_PWD=Oracle18_2
8+
APEX_REST_PUBLIC_USER_PWD=Oracle18_3
9+
ORDS_PUBLIC_USER_PWD=Oracle18_4
10+
INSTALL_FILE_APEX=apex_19.1.zip
11+
INSTALL_FILE_ORDS=ords-18.4.0.354.1002.zip
12+
INSTALL_FILE_JAVA=jdk-8u201-linux-x64.tar.gz
13+
DOCKER_ORDS_PORT=50080
14+
DOCKER_EM_PORT=55500
15+
DOCKER_DB_PORT=51521
16+
DB_VERSION=18.4.0
17+
DB_EDITION=xe

0 commit comments

Comments
 (0)