forked from fuzziebrain/docker-apex-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-build.sh
executable file
·130 lines (111 loc) · 4.83 KB
/
01-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
ENV_FILE=${1:-.env}
. $ENV_FILE
BASE_DIR=$(pwd -P)
DB_VERSION=${DB_VERSION:-18.4.0}
DB_EDITION=$(echo ${DB_EDITION:-xe} | tr '[:upper:]' '[:lower:]')
FILES_DIR=${FILES_DIR:-$BASE_DIR/files}
ALLOW_DB_PATCHING=${ALLOW_DB_PATCHING:-N}
OML4R_SUPPORT=${OML4R_SUPPORT:-N}
XE_DOWNLOAD_BASE_URL="https://download.oracle.com/otn-pub/otn_software/db-express/"
SED_OPTS='-i -r'
if [[ "$OSTYPE" == "darwin"* ]]; then
SED_OPTS='-i .bak -E'
fi
case "$DB_EDITION" in
"ee")
DB_EDITION_FLAG=-e
;;
"se2")
DB_EDITION_FLAG=-s
;;
*)
DB_EDITION_FLAG=-x
;;
esac
function setupR() {
echo "Installing R for Oracle ML Support"
# Copy the installR.sh to the base Docker directory.
cp -R $BASE_DIR/oml-kit/installR.sh .
# Modify the COPY statement.
sed $SED_OPTS "s|^(COPY)(.+CHECK_SPACE_FILE.+INSTALL_DIR/)$|\1 installR.sh\2|g" ${DOCKER_FILE:-Dockerfile}
REPLACEMENT_STRING=$'\$INSTALL_DIR/installR.sh \&\& \\\ \\\n '
sed $SED_OPTS "s|(rm -rf .INSTALL_DIR.*)$|${REPLACEMENT_STRING}\1|g" ${DOCKER_FILE:-Dockerfile}
}
if [ -d 'dockerfiles' ]; then
rm -rf dockerfiles;
fi
echo "##### Grabbing official Docker images from Oracle #####"
git clone https://github.com/oracle/docker-images.git tmp
mv tmp/OracleDatabase/SingleInstance/dockerfiles/ .
rm -rf tmp/
echo "##### Staging RPM #####"
if [ $DB_VERSION = '21.3.0' ]; then
if [ $DB_EDITION = 'xe' ]; then
DOCKER_FILE=Dockerfile.$DB_EDITION
if [[ $XE_USE_LOCAL_COPY =~ (Y|y) ]]; then
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/oracle-database-xe-21c-1.0-1.ol7.x86_64.rpm
sed $SED_OPTS "s|${XE_DOWNLOAD_BASE_URL}||g" ${DOCKER_FILE:-Dockerfile}
sed $SED_OPTS "s|^(COPY)(.+CHECK_SPACE_FILE.+INSTALL_DIR/)$|\1 \$INSTALL_FILE_1\2|g" ${DOCKER_FILE:-Dockerfile}
fi
else
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/LINUX.X64_213000_db_home.zip
DOCKER_FILE=Dockerfile
fi
elif [ $DB_VERSION = '19.3.0' ]; then
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/LINUX.X64_193000_db_home.zip
DOCKER_FILE=Dockerfile
elif [ $DB_VERSION = '18.4.0' ] && [ $DB_EDITION = 'xe' ]; then
DOCKER_FILE=Dockerfile.$DB_EDITION
if [[ $XE_USE_LOCAL_COPY =~ (Y|y) ]]; then
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/oracle-database-xe-18c-1.0-1.x86_64.rpm
sed $SED_OPTS "s|${XE_DOWNLOAD_BASE_URL}||g" ${DOCKER_FILE:-Dockerfile}
sed $SED_OPTS "s|^(COPY)(.+CHECK_SPACE_FILE.+INSTALL_DIR/)$|\1 \$INSTALL_FILE_1\2|g" ${DOCKER_FILE:-Dockerfile}
fi
elif [ $DB_VERSION = '18.3.0' ]; then
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/LINUX.X64_180000_db_home.zip
DOCKER_FILE=Dockerfile
elif [ $DB_VERSION = '12.2.0.1' ]; then
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/linuxx64_12201_database.zip
DOCKER_FILE=Dockerfile
elif [ $DB_VERSION = '12.1.0.2' ]; then
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/linuxamd64_12102_database_1of2.zip
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/linuxamd64_12102_database_2of2.zip
DOCKER_FILE=Dockerfile.$DB_EDITION
elif [ $DB_VERSION = '11.2.0.2' ]; then
cd dockerfiles/$DB_VERSION && curl --progress-bar -O file://$FILES_DIR/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
DOCKER_FILE=Dockerfile.$DB_EDITION
else
echo "Unknown or unsupported database version and/or edition."
fi
# TODO: test OML4R support for 21.3.0
if [[ $OML4R_SUPPORT =~ (Y|y) ]]; then
if [[
($DB_VERSION = '19.3.0')
|| ($DB_VERSION = '18.4.0' && $DB_EDITION = 'xe')
|| ($DB_VERSION = '18.3.0')
# || ($DB_VERSION = '12.2.0.1')
]]; then
setupR
fi
fi
cd $BASE_DIR
# RTU_ENABLED default 'N'
# The following is used for preparing "ready to use" images for internal use only.
if [[ $RTU_ENABLED =~ (Y|y) ]]; then
echo "##### Modify target Dockerfile #####"
REPLACEMENT_STRING=$'COPY scripts/setup/ \$ORACLE_BASE/scripts/setup/\\\nCOPY scripts/startup/ \$ORACLE_BASE/scripts/startup/\\\nCOPY files/ /tmp/files/\\\n'
sed $SED_OPTS "s|^VOLUME.+$|${REPLACEMENT_STRING}|g" dockerfiles/${DB_VERSION}/${DOCKER_FILE:-Dockerfile}
mkdir -p dockerfiles/${DB_VERSION}/files
cp $FILES_DIR/$INSTALL_FILE_APEX $FILES_DIR/$INSTALL_FILE_ORDS $FILES_DIR/$INSTALL_FILE_JAVA dockerfiles/${DB_VERSION}/files/
cp -R scripts dockerfiles/${DB_VERSION}/scripts
fi
# Retain the DBUA to allow DB patching. See https://github.com/oracle/docker-images/issues/1187
if [[ $ALLOW_DB_PATCHING =~ (Y|y) ]]; then
echo "##### Preventing removal of DBUA #####"
find dockerfiles -name installDBBinaries.sh -exec sed $SED_OPTS "s|^(\s*?rm.+ORACLE_HOME.+)$|#\1|g" {} \;
fi
echo "##### Building Docker Image for Oracle Database ${DB_VERSION} ${DB_EDITION} #####"
cd dockerfiles && . buildContainerImage.sh -v ${DB_VERSION} ${DB_EDITION_FLAG}
cd $BASE_DIR
echo "##### Done #####"