An easy way to try OpenWhisk locally is to use Docker Compose.
The following are required to build and deploy OpenWhisk with Docker Compose:
Available Ports:
5984
for CouchDB2181
for Zookeeper9092
for Kafka8400
, 8500
, 8600
, 8302
for Consul8888
for OpenWhisk's Controller8085
for OpenWhisk's Invoker80
and 443
for the API Gatewaymake quick-start
This command downloads the master
branch from the OpenWhisk repo, it builds OpenWhisk, the docker containers, it starts the system and it executes a simple hello-world
function. At the end of the execution it prints the output of the function:
{ "payload": "Hello, World!" }
If PROJECT_HOME
variable is set ( i.e. PROJECT_HOME=/path/to/openwhisk make quick-start
) then the command skips downloading the master
branch and uses instead the source code found in the PROJECT_HOME
folder. This is useful for working with a local clone, making changes to the code, and run it with docker-compose
.
make docker
This command builds the docker containers for local testing and development.
NOTE: The build may skip some components such as Swift actions in order to finish the build faster.
make run
This command starts OpenWhisk by calling docker-compose up
, it initializes the database and the CLI.
The following command stops the docker-compose
:
make stop
To remove the stopped containers, clean the database files and the temporary files use:
make destroy
Once OpenWhisk is up and running you can execute a hello-world
function:
make hello-world
This command creates a new JS action, it invokes it, and then it deletes it. The javascript action is:
function main(params) { var name = params.name || "World"; return {payload: "Hello, " + name + "!"}; }
The result of the invokation should be printed on the terminal:
{ "payload": "Hello, World!" }
~/tmp/openwhisk/controller/logs/
~/tmp/openwhisk/invoker/logs/
docker-compose
logs - ~/tmp/openwhisk/docker-compose.log
To start docker-compose
with custom images used for running actions use the following 2 variables:
DOCKER_REGISTRY
- specify a custom docker registry. I.e DOCKER_REGISTRY=registry.example.com make quick-start
DOCKER_IMAGE_PREFIX
- specify a custom image prefix. I.e. DOCKER_IMAGE_PREFIX=my-prefix make quick-start
These 2 variable allow you to execute a JS action using the container registry.example.com/my-prefix/nodejs6action
.