Skip to content

Commit caf9bc8

Browse files
repo create
1 parent c0fac41 commit caf9bc8

File tree

1 file changed

+50
-2
lines changed
  • app-dev/devops-and-containers/functions/java-helloworld-with-local-dev-and-oci-functions

1 file changed

+50
-2
lines changed

app-dev/devops-and-containers/functions/java-helloworld-with-local-dev-and-oci-functions/README.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ SOFTWARE.
4646

4747
This is an example how I'm locally developing and testing OCI Functions on my mac with Apple silicon that uses mainly ARM architecture and then building and deploying the same to Functions in OCI.
4848

49-
<p>
49+
### Local Dev
5050

5151
I've installed maven and <code>Fn cli</code> on my mac. This is how to do the <a href="https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsinstallfncli.htm">Fn cli install</a> or like in here <a href="https://fnproject.io/tutorials/install/">following the Fn tutorial</a>.
5252

@@ -98,7 +98,7 @@ echo 'Mika' | fn invoke hellofunction hellofunc
9898
Hello, Mika!
9999
</pre>
100100

101-
<p>
101+
### OCI
102102

103103
Now that the function is properly working locally let's build and deploy it to OCI.
104104

@@ -108,4 +108,52 @@ First create a OCIR repo for the container in your OCI tenancy <code>compartment
108108

109109
<p>
110110

111+
Next, let's build the Docker container for the function using <code>docker build</code>, let's not use Fn this time (that is also possible), using the FRA region:
112+
113+
<pre>
114+
docker build -t fra.ocir.io/&lt;YOUR OCI TENANCY NAMESPACE&gt;/helloworld-java:1 .
115+
</pre>
116+
117+
In the docker build command above replace the <code>region</code> if necessary and the &lt;YOUR OCI TENANCY NAMESPACE&gt; with yours.
118+
119+
<p>
120+
121+
After building let's do <code>docker login</code> and <code>docker push</code> to push the container to the OCIR repo:
122+
123+
<p>
124+
125+
<pre>
126+
docker login ams.ocir.io -u '&lt;YOUR OCI TENANCY NAMESPACE&gt;/oracleidentitycloudservice/&lt;YOUR USERNAME&gt;' -p '&lt;YOUR ACCESS TOKEN&gt;'
127+
docker push fra.ocir.io/&lt;YOUR OCI TENANCY NAMESPACE&gt;/helloworld-java:1
128+
</pre>
129+
130+
<p>
131+
132+
The last step is to create the Function Application and the function deployment for it. This can be easily done using the Cloud UI.
133+
134+
<p>
135+
136+
To create a mac binary compatible Function Application use the <code>shape GENERIC_ARM</code>. Let's name this <code>hello-arm</code>.
137+
138+
<p>
139+
140+
Create the Function from the container image that was pushed to the OCIR repo e.g. <code>fra.ocir.io/&lt;YOUR OCI TENANCY NAMESPACE&gt;/helloworld-java:1</code>. Let's name this <code>helloworld-java-arm</code>.
141+
142+
<p>
143+
144+
After deployment the Function can be easily tested in Cloud Shell following the Getting Started guide for the Application and giving:
145+
146+
<pre>
147+
echo 'Mika' | fn invoke hello-arm helloworld-java-arm
148+
Hello, Mika!
149+
</pre>
150+
151+
<p>
152+
153+
Optionally can create API Gateway for the function that will assign a public endpoint to it over HTTPS that can be easily tested with curl:
154+
155+
<pre>
156+
curl -d "Mika" https://n3yu.....ghhi.apigateway.eu-frankfurt-1.oci.customer-oci.com/
157+
Hello, Mika!
158+
</pre>
111159

0 commit comments

Comments
 (0)