Skip to content

Instantly share code, notes, and snippets.

@cvasani
Last active April 27, 2024 12:12
Show Gist options
  • Save cvasani/7b7788b43900f707f2f34f79cd8bb43c to your computer and use it in GitHub Desktop.
Save cvasani/7b7788b43900f707f2f34f79cd8bb43c to your computer and use it in GitHub Desktop.
Docker-Compose
-- https://phani-turlapati.medium.com/dbms-cloud-package-for-oracle-databases-5fcb32894bc4
-- cd /opt/oracle/product/19c/dbhome_1/rdbms/admin
-- $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u sys/"L+3HrKNFD<75?kVNrjwDw" --force_pdb_mode 'READ WRITE' -b dbms_cloud_install -d /opt/oracle/product/19c/dbhome_1/rdbms/admin -l /opt/oracle/product/19c/dbhome_1/rdbms/admin dbms_cloud_install.sql
@$ORACLE_HOME/rdbms/admin/sqlsessstart.sql
set verify off
-- you must not change the owner of the functionality to avoid future issues
define username='C##CLOUD$SERVICE'
create user &username no authentication account lock;
REM Grant Common User Privileges
grant INHERIT PRIVILEGES on user &username to sys;
grant INHERIT PRIVILEGES on user sys to &username;
grant RESOURCE, UNLIMITED TABLESPACE, SELECT_CATALOG_ROLE to &username;
grant CREATE ANY TABLE, DROP ANY TABLE, INSERT ANY TABLE, SELECT ANY TABLE,
CREATE ANY CREDENTIAL, CREATE PUBLIC SYNONYM, CREATE PROCEDURE, ALTER SESSION, CREATE JOB to &username;
grant CREATE SESSION, SET CONTAINER to &username;
grant SELECT on SYS.V_$MYSTAT to &username;
grant SELECT on SYS.SERVICE$ to &username;
grant SELECT on SYS.V_$ENCRYPTION_WALLET to &username;
grant read, write on directory DATA_PUMP_DIR to &username;
grant EXECUTE on SYS.DBMS_PRIV_CAPTURE to &username;
grant EXECUTE on SYS.DBMS_PDB_LIB to &username;
grant EXECUTE on SYS.DBMS_CRYPTO to &username;
grant EXECUTE on SYS.DBMS_SYS_ERROR to &username;
grant EXECUTE ON SYS.DBMS_ISCHED to &username;
grant EXECUTE ON SYS.DBMS_PDB_LIB to &username;
grant EXECUTE on SYS.DBMS_PDB to &username;
grant EXECUTE on SYS.DBMS_SERVICE to &username;
grant EXECUTE on SYS.DBMS_PDB to &username;
grant EXECUTE on SYS.CONFIGURE_DV to &username;
grant EXECUTE on SYS.DBMS_SYS_ERROR to &username;
grant EXECUTE on SYS.DBMS_CREDENTIAL to &username;
grant EXECUTE on SYS.DBMS_RANDOM to &username;
grant EXECUTE on SYS.DBMS_SYS_SQL to &username;
grant EXECUTE on SYS.DBMS_LOCK to &username;
grant EXECUTE on SYS.DBMS_AQADM to &username;
grant EXECUTE on SYS.DBMS_AQ to &username;
grant EXECUTE on SYS.DBMS_SYSTEM to &username;
grant EXECUTE on SYS.SCHED$_LOG_ON_ERRORS_CLASS to &username;
grant SELECT on SYS.DBA_DATA_FILES to &username;
grant SELECT on SYS.DBA_EXTENTS to &username;
grant SELECT on SYS.DBA_CREDENTIALS to &username;
grant SELECT on SYS.AUDIT_UNIFIED_ENABLED_POLICIES to &username;
grant SELECT on SYS.DBA_ROLES to &username;
grant SELECT on SYS.V_$ENCRYPTION_KEYS to &username;
grant SELECT on SYS.DBA_DIRECTORIES to &username;
grant SELECT on SYS.DBA_USERS to &username;
grant SELECT on SYS.DBA_OBJECTS to &username;
grant SELECT on SYS.V_$PDBS to &username;
grant SELECT on SYS.V_$SESSION to &username;
grant SELECT on SYS.GV_$SESSION to &username;
grant SELECT on SYS.DBA_REGISTRY to &username;
grant SELECT on SYS.DBA_DV_STATUS to &username;
alter session set current_schema=&username;
REM Create the Catalog objects
@$ORACLE_HOME/rdbms/admin/dbms_cloud_task_catalog.sql
@$ORACLE_HOME/rdbms/admin/dbms_cloud_task_views.sql
@$ORACLE_HOME/rdbms/admin/dbms_cloud_catalog.sql
@$ORACLE_HOME/rdbms/admin/dbms_cloud_types.sql
REM Create the Package Spec
@$ORACLE_HOME/rdbms/admin/prvt_cloud_core.plb
@$ORACLE_HOME/rdbms/admin/prvt_cloud_task.plb
@$ORACLE_HOME/rdbms/admin/dbms_cloud_capability.sql
@$ORACLE_HOME/rdbms/admin/prvt_cloud_request.plb
@$ORACLE_HOME/rdbms/admin/prvt_cloud_internal.plb
@$ORACLE_HOME/rdbms/admin/dbms_cloud.sql
@$ORACLE_HOME/rdbms/admin/prvt_cloud_admin_int.plb
REM Create the Package Body
@$ORACLE_HOME/rdbms/admin/prvt_cloud_core_body.plb
@$ORACLE_HOME/rdbms/admin/prvt_cloud_task_body.plb
@$ORACLE_HOME/rdbms/admin/prvt_cloud_capability_body.plb
@$ORACLE_HOME/rdbms/admin/prvt_cloud_request_body.plb
@$ORACLE_HOME/rdbms/admin/prvt_cloud_internal_body.plb
@$ORACLE_HOME/rdbms/admin/prvt_cloud_body.plb
@$ORACLE_HOME/rdbms/admin/prvt_cloud_admin_int_body.plb
-- Create the metadata
@$ORACLE_HOME/rdbms/admin/dbms_cloud_metadata.sql
alter session set current_schema=sys;
@$ORACLE_HOME/rdbms/admin/sqlsessend.sql
---
version: "3"
services:
adw:
container_name: adw
ports:
- 1521:1521
- 5500:5500
- 2484:2484
- 8443:8443 # HTTPS for ORDS/APEX
- 27017:27017 # Mongo API
- 53505:53505 # Debug API
- 53506:53506 # Debug API
ulimits:
nofile:
soft: 1024
hard: 65536
nproc:
soft: 2047
hard: 16384
stack:
soft: 10485760
hard: 33554432
environment:
- ORACLE_SID=xe
- ORACLE_PDB=pdb1
- ORACLE_PWD=L+3HrKNFD<75?kVNrjwDw
volumes:
- oracle_volume_adw:/opt/oracle/oradata
- scripts_volume:/opt/oracle/sql_scripts/:z
image: oracle/database:19.3.0-ee
# oracle-sqlcl:
# container_name: sqlcl
# image: container-registry.oracle.com/database/sqlcl:latest
# volumes:
# - scripts_volume:/opt/oracle/sql_scripts/:z
# stdin_open: true
# tty: true
# links:
# - adw:adw
oracle-lq:
container_name: lb
image: localhost/ldo:latest
volumes:
- scripts_volume:/opt/oracle/sql_scripts/:z
stdin_open: true
tty: true
links:
- adw:adw
command: tail -F /dev/null
volumes:
oracle_volume_adw:
external: true
name: oracle_volume_adw
scripts_volume:
external: true
name: scripts_volume
# https://container-registry.oracle.com/ords/f?p=113:4:4515759747700:::4:P4_REPOSITORY,AI_REPOSITORY,AI_REPOSITORY_NAME,P4_REPOSITORY_NAME,P4_EULA_ID,P4_BUSINESS_AREA_ID:2223,2223,Oracle%20Autonomous%20Database%20Free,Oracle%20Autonomous%20Database%20Free,1,0&cs=3oVq4ARriDndL_icgLKFc5rGAtLmNU1M_M7F2HkXxc01y8pMHRGnJT_5IZY-fTRRE-FvPvaePiV7s5bHKo9WWfA
# sudo chmod -R 777 sql_scripts
# docker cp 4d544c4fe497:/u01/app/oracle/wallets/tls_wallet tls_wallet
# sudo chmod -R 777 sql_scripts
# docker exec -it project-oracle-sqlcl-1 /opt/oracle/sqlcl/bin/sql /nolog
# export TNS_ADMIN=/opt/oracle/sql_scripts/tls_wallet
# sed -i 's/localhost/oracle-xe/g' $TNS_ADMIN/tnsnames.ora
# connect admin@myadw_low
# APEX https://localhost:8443/ords/apex
# Database Actions https://localhost:8443/ords/sql-developer
# my_nice_@Atp_PW123
# db.wallet.zip.path=/u01/ords/wallet.zip
# connect "sys as sysdba"@adwdb:1521:XE
# /opt/oracle/sqlcl/bin/sql sys/"L+3HrKNFD<75?kVNrjwDw"@'(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = adwdb)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PDB1)))' as sysdba
# docker volume create oracle_volume_adw
# docker-compose -f docker-compose-ADB.yaml up
# docker volume create scripts_volume
# cd /opt/oracle/product/19c/dbhome_1/rdbms/admin
# https://phani-turlapati.medium.com/dbms-cloud-package-for-oracle-databases-5fcb32894bc4
# $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u sys/"L+3HrKNFD<75?kVNrjwDw" --force_pdb_mode 'READ WRITE' -b dbms_cloud_install -d /opt/oracle/product/19c/dbhome_1/rdbms/admin -l /opt/oracle/product/19c/dbhome_1/rdbms/admin dbms_cloud_install.sql

version: '3.8' services: oracle-xe: environment: - ORACLE_PASSWORD=oracle image: gvenzl/oracle-xe:slim-faststart ports: - "1521:1521" restart: unless-stopped volumes: - oracle-volume:/opt/oracle/oradata

oracle-sqlcl: image: container-registry.oracle.com/database/sqlcl:latest volumes: - ./sql_scripts:/opt/oracle/sql_scripts/ stdin_open: true tty: true links: - oracle-xe:oracle-xe volumes: oracle-volume:

FROM liquibase/liquibase:latest-alpine
ENV ORACLE_BASE /usr/lib/instantclient
ENV LD_LIBRARY_PATH /usr/lib/instantclient
ENV TNS_ADMIN /usr/lib/instantclient
ENV ORACLE_HOME /usr/lib/instantclient
# Install SQLPlus
USER root
# Install Instantclient Basic Light Oracle and Dependencies
RUN apk --no-cache add libaio libnsl libc6-compat curl && \
cd /tmp && \
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL && \
unzip instantclient-basiclite.zip && \
mv instantclient*/ /usr/lib/instantclient && \
rm instantclient-basiclite.zip && \
ln -s /usr/lib/instantclient/libclntsh.so.19.1 /usr/lib/libclntsh.so && \
ln -s /usr/lib/instantclient/libocci.so.19.1 /usr/lib/libocci.so && \
ln -s /usr/lib/instantclient/libociicus.so /usr/lib/libociicus.so && \
ln -s /usr/lib/instantclient/libnnz19.so /usr/lib/libnnz19.so && \
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 && \
ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \
ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2
# Return to liquibase user space
USER liquibase
# docker build - < Dockerfile.alpine.sqlplus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment