Skip to content

Commit 49322d1

Browse files
repo create
1 parent 88aeafa commit 49322d1

File tree

2 files changed

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

2 files changed

+37
-1
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,41 @@ SOFTWARE.
4444

4545
# A Java Hello World function with local dev and then building and deploying to OCI Functions
4646

47+
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.
4748

49+
<p>
50+
51+
I've installed maven and <code>Fn cli</code> on my mac. Thisn is how to do the <a href="https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsinstallfncli.htm">Fn cli install</a> or here <a href="https://fnproject.io/tutorials/install/">following the Fn tutorial</a>.
52+
53+
<p>
54+
55+
To develop functions locally I'm running the Fn server; to do this I'm using this command with Rancher Desktop instead of doing the usual <code>fn start</code> that works for me:
56+
57+
<pre>
58+
docker run --rm -i --name fnserver \
59+
-v /tmp/iofs:/iofs \
60+
-e FN_IOFS_DOCKER_PATH=/tmp/iofs \
61+
-e FN_IOFS_PATH=/iofs \
62+
-v /tmp/data:/app/data \
63+
-v /var/run/docker.sock:/var/run/docker.sock \
64+
--privileged \
65+
-p 8080:8080 \
66+
--entrypoint ./fnserver \
67+
-e FN_LOG_LEVEL=DEBUG fnproject/fnserver:latest
68+
</pre>
69+
70+
<p>
71+
Now that the Fn server is running create an application for our function using the cli:
72+
73+
<pre>
74+
fn create app hellofunction
75+
</pre>
76+
77+
<p>
78+
79+
Then clone this repo and project and cd to the project root directory. Then run Fn cli command to build and deploy the function locally:
80+
81+
<pre>
82+
fn --verbose deploy --app hellofunction --local
83+
</pre>
4884

app-dev/devops-and-containers/functions/java-helloworld-with-local-dev-and-oci-functions/src/main/java/com/example/HelloFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public String handleRequest(String input) {
4444
String name = (input == null || input.isEmpty()) ? "world" : input;
4545

4646
System.out.println("Inside Java Hello World function");
47-
return "Hello, " + name + "!";
47+
return "Hello, " + name.strip() + "!";
4848
}
4949

5050
}

0 commit comments

Comments
 (0)