-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_local.sh
More file actions
executable file
·60 lines (48 loc) · 2.17 KB
/
run_local.sh
File metadata and controls
executable file
·60 lines (48 loc) · 2.17 KB
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
#!/usr/bin/env bash
set -euo pipefail
IMAGE="${IMAGE:-simple-oracle-udf}"
CONTAINER="${CONTAINER:-oracle-udf}"
PLATFORM="${PLATFORM:-linux/amd64}"
ORACLE_PASSWORD="${ORACLE_PASSWORD:-YourPwd123}"
echo "[build] docker build --platform ${PLATFORM} -t ${IMAGE} ."
docker build --platform "${PLATFORM}" -t "${IMAGE}" .
echo "[clean] removing container ${CONTAINER} if present"
docker rm -f "${CONTAINER}" 2>/dev/null || true
echo "[clean] removing oracle* volumes (if any) to force fresh DB init"
for vol in $(docker volume ls --format '{{.Name}}' | grep -E '^oracle' || true); do
docker volume rm "${vol}" || true
done
echo "[run] starting ${CONTAINER} (${PLATFORM})"
docker run --platform "${PLATFORM}" -d --name "${CONTAINER}" \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_PASSWORD="${ORACLE_PASSWORD}" \
"${IMAGE}"
echo "[wait] waiting for DATABASE IS READY TO USE"
max_tries=120
count=0
until docker logs "${CONTAINER}" 2>&1 | grep -q "DATABASE IS READY TO USE"; do
sleep 5
count=$((count + 1))
if [ "${count}" -ge "${max_tries}" ]; then
echo "Timed out waiting for database readiness"
docker logs "${CONTAINER}"
exit 1
fi
done
echo "[ready] database is ready"
echo "[log] install log (if present)"
docker exec "${CONTAINER}" sh -c "if [ -f /opt/oracle/udf/install.log ]; then cat /opt/oracle/udf/install.log; else echo 'install.log not found'; fi"
echo "[log] setup/startup scripts present:"
docker exec "${CONTAINER}" sh -c "ls -l /opt/oracle/scripts/setup /opt/oracle/scripts/startup"
echo "[install] running string_udf.sql"
docker exec "${CONTAINER}" sh -c "sqlplus -s / as sysdba @/opt/oracle/udf/string_udf.sql"
echo "[verify] checking library and function"
docker exec "${CONTAINER}" sh -c "sqlplus -s system/${ORACLE_PASSWORD}@localhost/XEPDB1 <<'SQL'
select owner, object_name, status from dba_objects where object_name='STRING_UDF_WRAPPER';
select library_name, file_spec from dba_libraries where library_name='STRING_UDF_LIB';
show errors function string_udf_wrapper;
exit;
SQL"
echo "[test] running example.sql"
docker exec "${CONTAINER}" sqlplus -s system/"${ORACLE_PASSWORD}"@localhost/XEPDB1 @/opt/oracle/udf/example.sql
echo "[done] container ${CONTAINER} operational"