Skip to content

Commit ce470d3

Browse files
committed
working on base docker file
1 parent abe4a81 commit ce470d3

File tree

6 files changed

+174
-74
lines changed

6 files changed

+174
-74
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ target
77

88
.idea
99

10+
SECRETS.md

Dockerfile

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ RUN apk update && apk add libaio libnsl && \
88
RUN apk add --update \
99
git \
1010
maven \
11+
wget \
1112
&& rm -rf /var/cache/apk/*
1213

13-
# get oracle instant client from bumpx git repo
14-
# ENV CLIENT_FILENAME instantclient-basic-linux.x64-12.1.0.1.0.zip
15-
ENV CLIENT_FILENAME instantclient-sqlplus-linux.x64-12.1.0.1.0.zip
14+
# === INSTANT CLIENT ===
15+
# get oracle instant client from bumpx git repo
16+
ENV CLIENT_FILENAME instantclient-basic-linux.x64-12.1.0.1.0.zip
17+
# ENV CLIENT_FILENAME instantclient-sqlplus-linux.x64-12.1.0.1.0.zip
1618

17-
WORKDIR /opt/oracle/lib
18-
19-
# download instant client zip file from git repo
19+
WORKDIR /opt/oracle
2020
ADD https://github.com/bumpx/oracle-instantclient/raw/master/${CLIENT_FILENAME} .
2121

2222
RUN LIBS="*/libociei.so */libons.so */libnnz12.so */libclntshcore.so.12.1 */libclntsh.so.12.1" && \
@@ -25,18 +25,55 @@ RUN LIBS="*/libociei.so */libons.so */libnnz12.so */libclntshcore.so.12.1 */libc
2525
ln -s /usr/lib/libclntsh.so.12.1 /usr/lib/libclntsh.so && \
2626
rm ${CLIENT_FILENAME}
2727

28-
ENV ORACLE_BASE /opt/oracle/lib/instantclient_12_1
29-
ENV LD_LIBRARY_PATH /opt/oracle/lib/instantclient_12_1
30-
ENV ORACLE_HOME /opt/oracle/lib/instantclient_12_1
31-
ENV TNS_ADMIN /opt/oracle/lib/wallet_NODEAPPDB2
32-
ENV PATH /opt/oracle/lib/instantclient_12_1:$PATH
28+
ENV ORACLE_BASE /opt/oracle/instantclient_12_1
29+
ENV LD_LIBRARY_PATH /opt/oracle/instantclient_12_1
30+
ENV ORACLE_HOME /opt/oracle/instantclient_12_1
31+
ENV PATH /opt/oracle/instantclient_12_1:$PATH
32+
33+
# === SQLcl ===
34+
ENV SQLCL_DIR /opt/oracle/sqlcl
35+
RUN mkdir ${SQLCL_DIR}
36+
WORKDIR ${SQLCL_DIR}
37+
RUN wget --content-disposition https://github.com/kbhanush/sqlcl4.2/blob/master/sqlcl-4.2.0.16.260.1205-no-jre.zip?raw=true
38+
RUN unzip sqlcl*
39+
ENV PATH=${SQLCL_DIR}/bin:$PATH
40+
41+
# === Java SDK ===
42+
# sdk in /opt/oracle/tools/java/sdk/oci-java-sdk/lib
43+
# 3rd party libs in /opt/oracle/tools/java/sdk/oci-java-sdk/third-party/lib
44+
RUN mkdir /opt/oracle/database && \
45+
mkdir /opt/oracle/tools && \
46+
mkdir /opt/oracle/tools/cli && \
47+
mkdir /opt/oracle/tools/java && \
48+
mkdir /opt/oracle/tools/java/sdk
49+
50+
WORKDIR /opt/oracle/tools/java/sdk
51+
52+
ADD https://github.com/oracle/oci-java-sdk/releases/download/v1.2.47/oci-java-sdk.zip .
53+
RUN unzip oci-java-sdk.zip
54+
55+
ENV PATH $PATH:/opt/oracle/database
56+
ENV PATH $PATH:/opt/oracle/tools
57+
ENV PATH $PATH:/opt/oracle/tools/cli
58+
ENV PATH $PATH:/opt/oracle/tools/java
59+
ENV PATH $PATH:/opt/oracle/tools/java/sdk
60+
61+
# === ORACLE JDBC DRIVERS ===
62+
# in /opt/oracle/ojdbc8-full
63+
WORKDIR /opt/oracle/
64+
RUN wget --content-disposition https://github.com/sblack4/ojdbc8-full/blob/master/ojdbc8-full.tar.gz?raw=true && \
65+
tar xvzf ojdbc8-full.tar.gz
3366

3467
# add our app and stuff
35-
RUN mkdir /opt/ATP-REST-Java
36-
ADD . /opt/ATP-REST-Java
68+
69+
RUN mkdir /opt/oracle/apps && \
70+
mkdir /opt/oracle/apps/ATP-REST-Java
71+
ADD . /opt/oracle/apps/ATP-REST-Java
72+
ENV PATH $PATH:/opt/oracle/apps/ATP-REST-Java
73+
ENV TNS_ADMIN /opt/oracle/wallet
3774
RUN mkdir /root/.oci
3875
ADD ./.oci /root/.oci
3976

40-
WORKDIR /opt/ATP-REST-Java
77+
WORKDIR /opt/oracle/apps/ATP-REST-Java
4178
EXPOSE 3050
4279
CMD [ "sh", "run.sh" ]

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@ REST APIs for Oracle Autonomous Transaciton Processing Service written in Java
33

44

55
## Objectives
6-
- A base image based on frolvlad/alpine-glibc:alpine-3.8 that includes Oracle instant client 18.3, sqlplus and sqlcl for basic sql connectivity to an oracle ATP database
6+
- [x] A base image based on frolvlad/alpine-glibc:alpine-3.8 that includes Oracle instant client 18.3, sqlplus and sqlcl for basic sql connectivity to an oracle ATP database
77
https://hub.docker.com/r/frolvlad/alpine-glibc/
8-
- A python, **Java** and node.js image each built on the base image and layered with drivers to connect respective language programs to an ATP database seamlessly Oracle Cloud Infrastructure CLI
9-
- A sample program that can take a mapped ATP credentials .zip file and connect to the database
10-
- REST API language scripts for listing, creating, scaling, backing up an ATP instance. See documentation for available REST calls and sample node.js scripts https://github.com/kbhanush/ATP-REST-nodejs
11-
12-
13-
- Instant Client - /opt/oracle/instantclient
14-
- Credentials wallet - /opt/oracle/database/<ServiceName>/wallet — include both the zip file and the unzipped files in this folder
15-
- Tools and scripts- Based on language written in - replace language folder accordingly
16-
- /opt/oracle/tools/python/restapi
17-
- /opt/oracle/tools/python/sdk
18-
- /opt/oracle/tools/cli
19-
- /opt/oracle/tools/swingbench
20-
- Sample apps - /opt/oracle/apps/<app_name>
21-
- Set PATH variable to include all of the above
8+
- [x] A python, **Java** and node.js image each built on the base image and layered with drivers to connect respective language programs to an ATP database seamlessly Oracle Cloud Infrastructure CLI
9+
- [x] instant client
10+
- [x] SQLcl
11+
- [x] Java SDK
12+
- [x] Oracle JDBC driver
13+
- [x] API language scripts for listing, creating, scaling, backing up an ATP instance
14+
- [ ] A sample program that can take a mapped ATP credentials .zip file and connect to the database
15+
16+
17+
### folder stuff
18+
- [x] Instant Client - /opt/oracle/instantclient
19+
- [x] (user must scp later) Credentials wallet - /opt/oracle/database/\<ServiceName\>/wallet — include both the zip file and the unzipped files in this folder
20+
- [x] /opt/oracle/tools/java/restapi
21+
- [x] /opt/oracle/tools/java/sdk
22+
- [ ] Sample apps - /opt/oracle/apps/<app_name>
23+
- [ ] Set PATH variable to include all of the above
2224

2325
## About
2426
Try out the Oracle Cloud Infrastructure Java SDK! I've tried to make this as simple as possible, but to *reallly* use the SDK you must read the docs! For developing with the `java` SDK read the java sdk docs, but if all you want to do is run this app you can get by with the SDK/CLI configuration docs. They will walk you through getting the required values to authenticate.

base/Dockerfile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
FROM frolvlad/alpine-oraclejdk8:cleaned
2+
3+
# === UPDATE BASE IMAGE ====
4+
RUN echo "=== UPDATING BASE IMAGE ==="
5+
6+
RUN apk update && apk add libaio libnsl && \
7+
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1
8+
9+
RUN apk add --update \
10+
git \
11+
curl \
12+
bash \
13+
wget \
14+
gcc \
15+
make \
16+
openssl-dev \
17+
libffi-dev \
18+
musl-dev \
19+
clang \
20+
python3-dev \
21+
ncurses \
22+
&& rm -rf /var/cache/apk/*
23+
24+
25+
# === INSTALL INSTANT CLIENT ===
26+
RUN echo "=== INSTALLING INSTANT CLIENT ==="
27+
WORKDIR /opt/oracle
28+
29+
# get oracle instant client from bumpx git repo
30+
ENV CLIENT_FILENAME instantclient-basic-linux.x64-12.1.0.1.0.zip
31+
ADD https://github.com/bumpx/oracle-instantclient/raw/master/${CLIENT_FILENAME} .
32+
33+
RUN LIBS="*/libociei.so */libons.so */libnnz12.so */libclntshcore.so.12.1 */libclntsh.so.12.1" && \
34+
unzip ${CLIENT_FILENAME} ${LIBS} && \
35+
for lib in ${LIBS}; do mv ${lib} /usr/lib; done && \
36+
ln -s /usr/lib/libclntsh.so.12.1 /usr/lib/libclntsh.so && \
37+
rm ${CLIENT_FILENAME}
38+
39+
ENV ORACLE_BASE /opt/oracle/instantclient_12_1
40+
ENV LD_LIBRARY_PATH /opt/oracle/instantclient_12_1
41+
ENV ORACLE_HOME /opt/oracle/instantclient_12_1
42+
ENV PATH /opt/oracle/instantclient_12_1:$PATH
43+
44+
45+
# === INSTALL SQLPLUS ===
46+
RUN echo "=== INSTALLING SQLPLUS ==="
47+
WORKDIR /opt/oracle
48+
49+
# get oracle instant client from bumpx git repo
50+
ENV CLIENT_FILENAME instantclient-sqlplus-linux.x64-12.1.0.1.0.zip
51+
ADD https://github.com/bumpx/oracle-instantclient/raw/master/${CLIENT_FILENAME} .
52+
53+
RUN unzip ${CLIENT_FILENAME} && \
54+
mkdir instantclient_12_1/bin && \
55+
mv instantclient_12_1/sqlplus instantclient_12_1/bin && \
56+
mkdir instantclient_12_1/sqlplus && \
57+
mkdir instantclient_12_1/sqlplus/admin && \
58+
mv instantclient_12_1/glogin.sql instantclient_12_1/sqlplus/admin && \
59+
mkdir instantclient_12_1/lib && \
60+
mv instantclient_12_1/*.so instantclient_12_1/lib
61+
62+
ENV PATH /opt/oracle/instantclient_12_1/bin:$PATH
63+
64+
65+
# === INSTALL SQLCL ===
66+
RUN echo '=== INSTALLING SQLCL ==='
67+
ENV SQLCL_DIR /opt/oracle/sqlcl
68+
RUN mkdir ${SQLCL_DIR}
69+
WORKDIR ${SQLCL_DIR}
70+
RUN wget --content-disposition https://github.com/kbhanush/sqlcl4.2/blob/master/sqlcl-4.2.0.16.260.1205-no-jre.zip?raw=true
71+
RUN unzip sqlcl*
72+
ENV PATH=${SQLCL_DIR}/sqlcl/bin:$PATH
73+
74+
75+
# === INSTALL OCI CLI ===
76+
WORKDIR /root
77+
RUN pip3 install oci-cli
78+
# RUN curl -O https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh
79+
80+

src/main/java/com/github/sblack4/atp/ATPSharedExample.java

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.github.sblack4.atp;
22

3-
/**
4-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
5-
*/
63
import com.oracle.bmc.Region;
74
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
85
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
@@ -28,8 +25,6 @@ public class ATPSharedExample {
2825
public static void main(String[] args) throws Exception {
2926
String configurationFilePath = "~/.oci/config";
3027
String profile = "DEFAULT";
31-
32-
// TODO: Fill in these values
3328
String compartmentId = args[0];
3429

3530
AuthenticationDetailsProvider provider =
@@ -42,30 +37,24 @@ public static void main(String[] args) throws Exception {
4237

4338
// Create
4439
CreateAutonomousDatabaseDetails createRequest = createAtpRequest(compartmentId);
45-
46-
System.out.println(
47-
"Creating Autonomous Transaction Processing Shared with request : \n"
48-
+ createRequest);
40+
System.out.println("Creating Autonomous Transaction Processing Shared with request : \n" + createRequest);
4941
AutonomousDatabase atpShared = createATP(dbClient, createRequest);
5042
System.out.println("ATP Shared instance is provisioning : " + atpShared);
5143

5244
atpShared = waitForInstanceToBecomeAvailable(dbClient, atpShared.getId());
5345
System.out.println("Instance is provisioned:" + atpShared);
5446

5547
// Get
56-
atpShared =
57-
dbClient.getAutonomousDatabase(
58-
GetAutonomousDatabaseRequest.builder()
59-
.autonomousDatabaseId(atpShared.getId())
60-
.build())
61-
.getAutonomousDatabase();
48+
atpShared = dbClient.getAutonomousDatabase(
49+
GetAutonomousDatabaseRequest.builder()
50+
.autonomousDatabaseId(atpShared.getId())
51+
.build()
52+
).getAutonomousDatabase();
6253
System.out.println("GET request returned :" + atpShared);
6354

6455
// Scale
6556
UpdateAutonomousDatabaseDetails updateRequest = scaleAtpRequest();
66-
System.out.println(
67-
"Updating Autonomous Transaction Processing Shared with request : "
68-
+ updateRequest);
57+
System.out.println("Updating Autonomous Transaction Processing Shared with request : " + updateRequest);
6958
AutonomousDatabase updatedAtpShared = updateATP(dbClient, updateRequest, atpShared.getId());
7059
System.out.println("ATP Shared instance is scaling : " + updatedAtpShared);
7160

@@ -74,33 +63,27 @@ public static void main(String[] args) throws Exception {
7463

7564
// Update Display Name
7665
updateRequest = updateDisplayNameAtpRequest();
77-
System.out.println(
78-
"Updating Autonomous Transaction Processing Shared with request : "
79-
+ updateRequest);
66+
System.out.println("Updating Autonomous Transaction Processing Shared with request : " + updateRequest);
8067
updatedAtpShared = updateATP(dbClient, updateRequest, updatedAtpShared.getId());
81-
8268
System.out.println("Instance is updated:" + updatedAtpShared);
8369

8470
// Stop
85-
System.out.println(
86-
"Stopping Autonomous Transaction Processing Shared : " + updatedAtpShared);
87-
atpShared =
88-
dbClient.stopAutonomousDatabase(
89-
StopAutonomousDatabaseRequest.builder()
90-
.autonomousDatabaseId(updatedAtpShared.getId())
91-
.build())
92-
.getAutonomousDatabase();
71+
System.out.println("Stopping Autonomous Transaction Processing Shared : " + updatedAtpShared);
72+
atpShared = dbClient.stopAutonomousDatabase(
73+
StopAutonomousDatabaseRequest.builder()
74+
.autonomousDatabaseId(updatedAtpShared.getId())
75+
.build()
76+
).getAutonomousDatabase();
9377
atpShared = waitForInstanceToBeStopped(dbClient, atpShared.getId());
9478
System.out.println("Stopped Autonomous Transaction Processing Shared : " + atpShared);
9579

9680
// Start
9781
System.out.println("Starting Autonomous Transaction Processing Shared : " + atpShared);
98-
atpShared =
99-
dbClient.startAutonomousDatabase(
100-
StartAutonomousDatabaseRequest.builder()
101-
.autonomousDatabaseId(updatedAtpShared.getId())
102-
.build())
103-
.getAutonomousDatabase();
82+
atpShared = dbClient.startAutonomousDatabase(
83+
StartAutonomousDatabaseRequest.builder()
84+
.autonomousDatabaseId(updatedAtpShared.getId())
85+
.build()
86+
).getAutonomousDatabase();
10487
atpShared = waitForInstanceToBecomeAvailable(dbClient, atpShared.getId());
10588
System.out.println("Started Autonomous Transaction Processing Shared : " + atpShared);
10689

@@ -111,13 +94,12 @@ public static void main(String[] args) throws Exception {
11194
.autonomousDatabaseId(updatedAtpShared.getId())
11295
.build());
11396
DatabaseWaiters waiter = dbClient.getWaiters();
114-
GetAutonomousDatabaseResponse response =
115-
waiter.forAutonomousDatabase(
116-
GetAutonomousDatabaseRequest.builder()
117-
.autonomousDatabaseId(atpShared.getId())
118-
.build(),
119-
AutonomousDatabase.LifecycleState.Terminated)
120-
.execute();
97+
GetAutonomousDatabaseResponse response = waiter.forAutonomousDatabase(
98+
GetAutonomousDatabaseRequest.builder()
99+
.autonomousDatabaseId(atpShared.getId())
100+
.build(),
101+
AutonomousDatabase.LifecycleState.Terminated
102+
).execute();
121103

122104
dbClient.close();
123105
}

src/main/java/com/github/sblack4/atp/AutonomousDatawarehouseExample.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public class AutonomousDatawarehouseExample {
2626
public static void main(String[] args) throws Exception {
2727
String configurationFilePath = "~/.oci/config";
2828
String profile = "DEFAULT";
29-
30-
// TODO: Fill in these values
3129
String compartmentId = args[0];
3230

3331
AuthenticationDetailsProvider provider =

0 commit comments

Comments
 (0)