About Application Container Cloud Service
ACCS provides a pre-configured platform (Platform as a Service or PAAS) where you can quickly deploy and host your applications. For many of today’s applications, the hosting server is just that, a place to host the application. Most of the time the only thing an application needs from the server is to have it support the application’s programming language and to provide in and out connections through ports. Using a PAAS such as ACCS frees you from all of the extra work of configuring and maintaining a server and allows you to focus on perfecting your application.
ACCS supports multiple languages but for this post, I’ll focus on Python.
DinoDate
For the examples, I will be deploying the DinoDate application. DinoDate was written as an open source learning application that can be used to demonstrate database concepts with multiple programming languages. It currently has both Python and NodeJS mid-tier applications and is backed by an Oracle Database.
The following instructions show how to deploy the Python version of DinoDate to an Oracle ACCS instance.
If you don’t have access to Oracle Cloud services, you can try the Oracle Cloud with $300 of free credit.
Download/Clone the DinoDate application.
Database
First, you’ll need a database.
Create an Oracle Cloud database or if you already have an Oracle Database, make sure that you can safely create and destroy the DD and DD_NON_EBR schema.
Connect to your database as sys with sysdba and run coreDatabase/dd_master_install.sql. (Use your password and connect string)
1 |
sql sys/YourPassword@YourJdbcConnecString as sysdba @coreDatabase/dd_master_install.sql |
Prepare the DinoDate Application
Download oraclejet.zip (version 4.1.0). (Current versions as of the time of this post.)
- Extract the Oracle JET files
- Run bower install
1 2 3 4 |
unzip oraclejet.zip -d dino-date/commonClient/jet/ cd dino-date/commonClient/jet/ bower install cd ../../ |
Download necessary files
The Docker container for Python used by ACCS comes with Python installed. We’ll need to include the rest of the dependencies.
- Oracle Instant Client Package – Basic Light (.zip file)
- Debian libaio package libaio1_0.3.110-1_amd64.deb
Package the Files to Deploy
- Create a deploy directory with a lib subdirectory.
- Copy the front end client into the deploy directory.
- Copy the python application into the deploy directory.
- Extract the Oracle instant client files into the deploy/lib directory. (Change the command to point to where your files are located.)
- Change to the deploy directory.
1 2 3 4 5 |
mkdir -p deploy/lib cp -r commonClient/ deploy/ cp -r python/ deploy/ unzip instantclient-basiclite-linux.x64-12.2.0.1.0.zip -d deploy/lib cd deploy |
1 2 3 4 5 6 7 8 9 10 11 |
#!/bin/sh # Install the LIBAOI libs dpkg-deb -R libaio1_0.3.110-1_amd64.deb ${APP_HOME} # Install Python packages into python/modules folder pip --no-cache-dir install -r python/requirements.txt -t ${PYTHONPATH} #launch DinoDate cd python python app.py |
This file declares that we will use Python version 3.6.0 and provides the command that will be used to start the application.
1 2 3 4 5 6 7 8 |
{ "runtime": { "majorVersion": "3.6.0" }, "command": "sh ./launchPython.sh", "release": {}, "notes": "DinoDate" } |
Create the deployment file: deployment.json
This file includes the environment variables DinoDate needs and sets the ACCS deployment to use 1G of memory and only install 1 instance. PYTHONPATH is the directory we will install the Python modules into and LD_LIBRARY_PATH is used by cx_Oracle to locate the Oracle client files.
Replace “YourJdbcConnecString” with the JDBC connect string for your database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{ "memory": "1G", "instances": "1", "environment": { "dd_connectString":"YourJdbcConnecString", "dd_user":"dd", "dd_password":"dd", "dd_clientAppCodeDir":"jet", "dd_python_clientAppCodeDir":"jet", "dd_python_port":"${PORT}", "PYTHONPATH":"${APP_HOME}/python/modules", "LD_LIBRARY_PATH":"${APP_HOME}/lib/instantclient_12_2:${APP_HOME}/lib/x86_64-linux-gnu" } } |
Important Note
ACCS is pre-configured to listen on $PORT so we set our application to listen on that port. Do not attempt to change $PORT. When ACCS performs its post-deploy check it will open the application using $PORT, if the application is not listening on that port and returns a 404 the deployment will fail and be removed.
Create a zip file with the required DinoDate deploy files.
1 |
zip -rq DinoDatePythonACCS.zip commonClient/ python/ lib/ libaio1_0.3.110-1_amd64.deb launchPython.sh |
Deploy to ACCS
In your browser navigate to the Oracle Application Container Cloud Service Console.
Push the Create Application button to open the platform selection panel.
Push the Python button to open the application definition panel and expand the ‘More Options’ section.
- Populate [Name] with DinoDatePython.
- Click ‘Choose File’ for Archive and select the DinoDatePythonACCS.zip file.
- Click ‘Choose File’ for Manifest and select the manifest.json file.
- Click ‘Choose File’ for Deployment Configuration and select the deployment.json file.
You can change the values in the other fields as you’d like, but notice that since we defined “memory”: “1G” and “instances”: “1” in the deployment.json file those values will change automatically.
It’s also possible to include the manifest.json file in the DinoDatePythonACCS.zip file instead of uploading it separately.
Click Create.
It may take several minutes for ACCS to setup the environment and deploy the application. Once it’s done click on the URL: link to open the application.
Try it out
You can log in with any of the existing users, such as:
- Bob
bob@example.com - Admin
admin@example.com
Use any value for the password, the application doesn’t check it.
Click on the Search tab and search for ‘eat’ it should return 6 of the pre-loaded dinosaurs.
Quick Review
- Download the dependencies.
- Create a launch script that will install the dependencies and launch the application.
- Collect the required deployment artifacts and dependencies into a .zip file.
- Create a manifest.json file that contains at least the required Python version and the command used to start your application.
- Create a deployment.json file that contains any needed environment variable definitions. Optionally you can include ACCS environment definitions such as required memory and number of instances. (This file is optional. You could include the environment variables in your launch script.)
Reminder: ACCS will use the pre-defined environment variable $PORT. Make sure your application listens on $PORT. - Use the ACCS service console to upload your 3 files and create your new application.
If you run into any trouble, leave a comment and I’ll be happy to help.
I simply wanted to thank you so much again. I am not sure the things
that I might have gone through without the type of hints revealed by
you regarding that situation.
Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.