Difficulty: beginner
Estimated Time: 20 minutes

This scenario introduces serverless Functions with Project Fn. It was prepared for the Meetup Workshop Cloud Native application development on Oracle Cloud Infrastructure on January 20th, hosted by AMIS|Conclusion in Nieuwegein in collaboration with REAL (the Red Expert Alliance) and Link from Portugal.

The scenario uses an Ubuntu 18.04 environment with Docker, Fn CLI and Fn Server running locally.

You will create Functions locally and deploy them to the local Fn Server. Functions can then be invoked through the Fn CLI or through regular HTTP clients such as CURL.

The scenario works with Node (JS) and Java as runtime languages. You can experiment with Go, Ruby, Python as runtimes just as easily.

Overview of Function running on Fn

Summary

This completes your explorations with Functions on a local Fn Server. The next scenario you may want to explore looks at deploying Function to Oracle Cloud Infrastructure.

Background Resources

Tutorial Getting Started with Fn environment https://github.com/fnproject/tutorials/blob/master/install/README.md

Tutorial FN with Node https://github.com/fnproject/tutorials/blob/master/node/intro/README.md

Docs on Fn on OCI https://docs.cloud.oracle.com/iaas/Content/Functions/Tasks/functionscreatefncontext.htm

Tutorials and other background resource for Project Fn: https://github.com/fnproject/tutorials/blob/master/README.md

Serverless Functions with Project Fn

Step 1 of 4

Step 1 - Install Fn and OCI environment

In this step, we will together prepare the environment for working with Fn. The Katacoda scenario environment runs Ubuntu and contains Docker. We need to add Fn CLI and Fn Server.

Wait for the Fn Server to be running

In the background we are currently preparing your Fn environment. Several Docker images are pulled and the Fn server is started. This takes up to three minutes. You can check if Fn Server is running by checking the currently running Docker containers using the following command:

docker ps

Do not continue until you see a Docker container running based on image fnproject/fnserver:latest Fn Server is running

Get going with Fn

Check the installed version - client and server - of Fn

fn version

List the currently available Fn contexts

fn list contexts

Notice we have a default context which deploys to a local Fn server. The default context is created the first time you run the Fn CLI. However, we need to select default as our current context and set a registry value for remote or local Docker use.

Set context to default - this is a local context that uses the locally running Fn server for deploying functions.

fn use context default

Before we start using Fn, we need to configure Fn to point to an appropriate Docker registry so it knows where to push your function images to. Normally Fn points to your Docker Hub account by specifying your Docker Hub username. However, for pure local development we can simply configure Fn with an arbitrary value

So now update the registry setting for the default content to something meaningless.

fn update context registry something-meaningless

You can list the currently available Fn contexts again and see whether your changes had an effect (of course they did)

fn list contexts