mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Some small cleanup to docs.
This commit is contained in:
committed by
Reed Allman
parent
ed46a61f51
commit
69f0201818
@@ -1,15 +1,18 @@
|
||||
# Packaging your Function
|
||||
|
||||
## Option 1 (recommended): Use the `fn` cli tool
|
||||
|
||||
We recommend using the [fn cli tool](../fn/README.md) which will handle all of this for you. But if you'd like to dig in
|
||||
and customize your images, look at Option 2.
|
||||
|
||||
## Option 2: Build your own images
|
||||
|
||||
Packaging a function has two parts:
|
||||
|
||||
* Create a Docker image for your function with an ENTRYPOINT
|
||||
* Push your Docker image to a registry (Docker Hub by default)
|
||||
|
||||
Once it's pushed to a registry, you can use it by referencing it when adding a route.
|
||||
|
||||
## Using fn
|
||||
|
||||
This is the easiest way to build, package and deploy your functions.
|
||||
Once it's pushed to a registry, you can use the image location when adding a route.
|
||||
|
||||
### Creating an image
|
||||
|
||||
@@ -17,7 +20,7 @@ The basic Dockerfile for most languages is along these lines:
|
||||
|
||||
```
|
||||
# Choose base image
|
||||
FROM golang:alpine
|
||||
FROM funcy/node:dev
|
||||
# Set the working directory
|
||||
WORKDIR /function
|
||||
# Add your binary or code to the working directory
|
||||
@@ -26,29 +29,16 @@ ADD funcbin /function/
|
||||
ENTRYPOINT ["./funcbin"]
|
||||
```
|
||||
|
||||
Then you simply build your function:
|
||||
Then build your function image:
|
||||
|
||||
```sh
|
||||
docker run --rm -v ${pwd}:/go/src/$FUNCPKG -w /go/src/$FUNCPKG funcy/go:dev go build -o funcbin
|
||||
docker build -t $USERNAME/myfunction .
|
||||
```
|
||||
|
||||
Or using [fn](../fn/README.md):
|
||||
|
||||
```sh
|
||||
fn build
|
||||
```
|
||||
|
||||
### Push your image
|
||||
|
||||
This part is simple:
|
||||
|
||||
```sh
|
||||
docker push $USERNAME/myfunction
|
||||
```
|
||||
|
||||
Or using [fn](../fn/README.md):
|
||||
|
||||
```sh
|
||||
fn push
|
||||
```
|
||||
Now you can use that image when creating or updating routes.
|
||||
|
||||
Reference in New Issue
Block a user