1. 说明
fnproject 默认的docker registry 是 dockerhub 对于企业应用还是不太方便的
还好系统系统了配置参数方便我们进行配置,与开源harbor 进行集成
2. 使用
a. harbor 安装
此处略过,安装比较简单,参考github 文档即可
b. 配置说明
1. 构建
func.yml
参考配置
NAME:
fn init - create a local func.yaml file
USAGE:
fn init [command options] [FUNCTION_NAME]
DESCRIPTION:
Creates a func.yaml file in the current directory.
OPTIONS:
--name value name of the function. Defaults to directory name.
--force overwrite existing func.yaml
--runtime value choose an existing runtime - .py, .rs, .java, .go, .js, .cs, .fs, .rb, .php
--entrypoint value entrypoint is the command to run to start this function - equivalent to Dockerfile ENTRYPOINT.
--cmd value command to run to start this function - equivalent to Dockerfile CMD.
--version value set initial function version (default: "0.0.1")
--image value, -i value image name
--memory value, -m value memory in MiB (default: 128)
--type value, -t value route type - sync or async
--config value, -c value route configuration
--headers value route response headers
--format value, -f value hot container IO format - default or http (default: "default")
--timeout value route timeout (eg. 30) (default: 30)
--idle-timeout value route idle timeout (eg. 30) (default: 30)
2. deploy
使用 --registry 即可
参考配置
NAME:
fn deploy - deploys a function to the functions server. (bumps, build, pushes and updates route)
USAGE:
fn deploy [command options] [arguments...]
OPTIONS:
--app value app name to deploy to
--verbose, -v verbose mode
--no-cache Don't use Docker cache for the build
--local, --skip-push does not push Docker built images onto Docker Hub - useful for local development.
--registry --registry username Sets the Docker owner for images and optionally the registry. This will be prefixed to your function name for pushing to Docker registries. eg: --registry username will set your Docker Hub owner. `--registry registry.hub.docker.com/username` will set the registry and owner.
--all app.yaml if in root directory containing app.yaml, this will deploy all functions
3. 注意
1. 需要进行 registry 的登录
登录命令为:
docker login registry
2.配置环境变量
FN_REGISTRY
如下:
export FN_REGISTRY=<DOCKERHUB_USERNAME>
4. 参考资料
https://github.com/fnproject/fn