Deploy your apps to Oracle Cloud using PaaS Service Manager CLI on Docker
This blog will give you a quick tour of Oracle PaaS Service Manager command line interface (PSM CLI in short) which provides a command line interface (CLI) to manage the lifecycle of various services (e.g. Oracle Application Container Cloud, Oracle Big Data Cloud Compute Edition, Oracle Java Cloud, Oracle Event Hub Cloud etc.) in Oracle Public Cloud
We will explore PSM CLI capabilities for Oracle Application Container Cloud (ACCS) to be specific (for all the PSM ACCS commands, refer the documentation)
- We will first Docker-ize the PSM CLI along with our application and once our Docker container is ready we will,
- execute various life cycle activities — deploy, check health, stop, delete etc.
Here is the blog which served as the inspiration/trigger for this one!
Dockerfile overview
Here is the Dockerfile along with a summary of what’s going on…
#1
FROM python:3.6.2-alpine3.6#2
ARG USERNAME
ARG PASSWORD
ARG IDENTITY_DOMAIN
ARG PSM_USERNAME
ARG PSM_PASSWORD
ARG PSM_REGION
ARG PSM_OUTPUT#3
WORKDIR “/oracle-cloud-psm-cli/”#4
RUN apk add --update curl && \
rm -rf /var/cache/apk/*#5
RUN curl -X GET -u $USERNAME:$PASSWORD -H X-ID-TENANT-NAME:$IDENTITY_DOMAIN https://psm.us.oraclecloud.com/paas/core/api/v1.1/cli/$IDENTITY_DOMAIN/client -o psmcli.zip#6
RUN pip3 install -U psmcli.zip#7
RUN echo -e “$PSM_USERNAME\n$PSM_PASSWORD\n$PSM_PASSWORD\n$IDENTITY_DOMAIN\n$PSM_REGION\n$PSM_OUTPUT” | psm setup#8
COPY accs-hello-world/target/accs-hello-world.zip .
COPY accs-hello-world/deployment.json .#9
CMD [“/bin/sh”]
- Base Docker Python image — the PaaS CLI needs Python
- Declare arguments (which will be used later during
docker build
) - setup working directory
- install
cURL
- download PSM CLI (using REST API)
- install Python package
- bootstrap PSM
- include sample application (zip) and
deployment.json
- specify default command to be executed when Docker container starts up
Let’s get going…
The application is available here.. to get started,
Clone the git repository
git clone https://github.com/abhirockzz/accs-psm-cli-docker.git
Build the application
mvn clean install
will create a target directory with accs-hello-world.zip
— this is the artifact which will be pushed to the cloud
Build Docker image
docker build --build-arg USERNAME=”foo@bar.com” --build-arg PASSWORD=”foobared" --build-arg IDENTITY_DOMAIN=”foodomain" --build-arg PSM_USERNAME=”foo@bar.com” --build-arg PSM_PASSWORD=”foobared" --build-arg PSM_REGION=”us” --build-arg PSM_OUTPUT=”json” -t psm-cli .
Execute docker images
— you should see psm-cli
in the list of images
Start Docker container
docker run --rm -it psm-cli
— you will land in the shell.. now its time to execute our commands
Sanity check
psm --version
Response: PSM CLI Client — version 1.1.16
Deploy application to Oracle Application Container Cloud
psm accs push -n HelloWorldApp -r java -s hourly -d deployment.json -p accs-hello-world.zip
Check (deployment) job status
We will use the Job ID (highlighted above) which was returned by the push operation
psm accs operation-status -j 14988917
Application info
psm accs app -n HelloWorldApp
Access the application URL
The sample application uses a simple JDK based HTTPServer
curl https://helloworldapp-<identity-domain>.apaas.us2.oraclecloud.com/
will return something like Hello @ Fri Sep 01 13:37:39 UTC 2017 from 10.199.34.135
Health check
psm accs check-health -n HelloWorldApp
Stop the application
psm accs stop -n HelloWorldApp
— process will be triggered
Track using Job ID (same as before) and check the status after some time using psm accs app -n HelloWorldApp
Delete the application
psm accs delete -n HelloWorldApp
— track progress using Job ID
That’s all folks !
Don’t forget to…
- check out the tutorials for Oracle Application Container Cloud — there is something for every runtime !
- other blogs on Application Container Cloud
The views expressed in this post are my own and do not necessarily reflect the views of Oracle.