Skip to content

Latest commit

 

History

History
96 lines (76 loc) · 3.83 KB

getting-started-docker.md

File metadata and controls

96 lines (76 loc) · 3.83 KB

Getting Started with Nuclio on Docker

Follow this step-by-step guide to set up a Nuclio development environment that uses Docker.

In this document

Prerequisites

Before starting the set-up procedure, ensure that the following prerequisites are met:

  • Your environment has a running Docker daemon. To ensure that your Docker daemon is running properly, run the following command with the same user that will be used to execute Nuclio CLI commands:

    docker version
  • The Nuclio CLI (nuctl) is installed — if you wish to use the CLI to deploy Nuclio functions. To install the CLI, simply download the appropriate CLI version to your installation machine.

Run Nuclio

Execute the following command from a command-line shell to run Nuclio on Docker.

Note: The stable tag refers to the latest version released from the master branch of the Nuclio repository (unlike versioned branches, such as 1.3.x).

docker run \
  --rm \
  --detach \
  --publish 8070:8070 \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp:/tmp \
  --name nuclio-dashboard \
  quay.io/nuclio/dashboard:stable-amd64

Deploy a function with the Nuclio dashboard

Browse to http://localhost:8070 to see the Nuclio dashboard. Select the "default" project and then select New Function from the action toolbar to display the Create function page (http://localhost:8070/projects/default/create-function). Choose one of the predefined template functions, and select Deploy. The first build populates the local Docker cache with base images and other files, so it might take a while to complete, depending on your network. When the function deployment completes, you can select Test to invoke the function with a body.

Deploy a function with the Nuclio CLI (nuctl)

Run the following Nuclio CLI (nuctl) command from a command-line shell to deploy the example helloworld Go function. You can add the --verbose flag if you want to peek under the hood.

nuctl deploy helloworld \
    --path https://raw.githubusercontent.com/nuclio/nuclio/master/hack/examples/golang/helloworld/helloworld.go

When the function deployment completes, you can get the function information by running the following CLI command:

nuctl get function helloworld

Sample output -

  NAMESPACE | NAME        | PROJECT | STATE | NODE PORT | REPLICAS  
  nuclio    | helloworld  | default | ready |     42089 | 1/1   

You can see from the sample output that the deployed function helloworld is running and using port 42089.

Run the following CLI command to invoke the function:

nuctl invoke helloworld --method POST --body '{"hello":"world"}' --content-type "application/json"

Sample output -

> Response headers:
Server = nuclio
Date = Thu, 18 Jun 2020 06:56:27 GMT
Content-Type = application/text
Content-Length = 21

> Response body:
Hello, from Nuclio :]

What's next?

See the following resources to make the best of your new Nuclio environment: