github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/docs/packaging.md (about)

     1  # Packaging your Function
     2  
     3  Packaging a function has two parts:
     4  
     5  * Create a Docker image for your function with an ENTRYPOINT
     6  * Push your Docker image to a registry (Docker Hub by default)
     7  
     8  Once it's pushed to a registry, you can use it by referencing it when adding a route.
     9  
    10  ## Using fn
    11  
    12  This is the easiest way to build, package and deploy your functions.
    13  
    14  
    15  
    16  
    17  
    18  ##
    19  
    20  ### Creating an image
    21  
    22  The basic Dockerfile for most languages is along these lines:
    23  
    24  ```
    25  # Choose base image
    26  FROM iron/go
    27  # Set the working directory
    28  WORKDIR /function
    29  # Add your binary or code to the working directory
    30  ADD funcbin /function/
    31  # Set what will run when a container is started for this image
    32  ENTRYPOINT ["./funcbin"]
    33  ```
    34  
    35  Then you simply build your function:
    36  
    37  ```sh
    38  docker run --rm -v ${pwd}:/go/src/$FUNCPKG -w /go/src/$FUNCPKG iron/go:dev go build -o funcbin
    39  docker build -t $USERNAME/myfunction .
    40  ```
    41  
    42  Or using [fn](../fn/README.md):
    43  
    44  ```sh
    45  fn build
    46  ```
    47  
    48  ### Push your image
    49  
    50  This part is simple:
    51  
    52  ```sh
    53  docker push $USERNAME/myfunction
    54  ```
    55  
    56  Or using [fn](../fn/README.md):
    57  
    58  ```sh
    59  fn push
    60  ```