fn project 私有镜像发布

本文介绍如何将fnproject与企业级容器注册表Harbor集成,包括安装Harbor、配置func.yml文件及fndeploy命令的具体用法,并提供配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
 
 
 
 
 
 
/* * INCLUDE FILES **************************************************************************************** */ #include <stdio.h> #include <string.h> #include "gap_api.h" #include "gatt_api.h" #include "ble_stack.h" #include "app_config.h" #include "jump_table.h" #include "co_log.h" #include "plf.h" #include "driver_system.h" #include "driver_pmu.h" #include "driver_uart.h" #include "ble_simple_central.h" #include "simple_gatt_service.h" #undef LOG_LOCAL_LEVEL #define LOG_LOCAL_LEVEL (LOG_LEVEL_INFO) const char *app_tag = "project"; #define SYSTEM_STACK_SIZE 0x800 void patch_init(void); /* * LOCAL VARIABLES */ __attribute__((section("stack_section"))) static uint32_t system_stack[SYSTEM_STACK_SIZE/sizeof(uint32_t)]; const struct jump_table_version_t _jump_table_version __attribute__((section("jump_table_3"))) = { .stack_top_address = &system_stack[SYSTEM_STACK_SIZE/sizeof(uint32_t)], .firmware_version = 0x00000000, }; const struct jump_table_image_t _jump_table_image __attribute__((section("jump_table_1"))) = { .image_type = IMAGE_TYPE_APP, .image_size = 0x19000, }; /********************************************************************* * @fn user_entry_before_sleep_imp * * @brief Before system goes to sleep mode, user_entry_before_sleep_imp() * will be called, MCU peripherals can be configured properly before * system goes to sleep, for example, some MCU peripherals need to be * used during the system is in sleep mode. * * @param None. * * * @return None. */ __attribute__((section("ram_code"))) void user_entry_before_sleep_imp(void) { pmu_calibration_stop(); uart_putc_noint_no_wait(UART0, 's'); co_delay_100us(1); pmu_set_pin_to_PMU(GPIO_PORT_A, (1<<GPIO_BIT_0)); pmu_set_pin_dir(GPIO_PORT_A, (1<<GPIO_BIT_0), GPIO_DIR_IN); pmu_set_pin_pull(GPIO_PORT_A, (1<<GPIO_BIT_0),GPIO_PULL_NONE); pmu_oscap_set(0); } /********************************************************************* * @fn user_entry_after_sleep_imp * * @brief After system wakes up from sleep mode, user_entry_after_sleep_imp() * will be called, MCU peripherals need to be initialized again, * this can be done in user_entry_after_sleep_imp(). MCU peripherals * status will not be kept during the sleep. * * @param None. * * * @return None. */ __attribute__((section("ram_code"))) void user_entry_after_sleep_imp(void) { pmu_set_pin_to_CPU(GPIO_PORT_A, (1<<GPIO_BIT_0)); system_set_port_mux(GPIO_PORT_A, GPIO_BIT_0, PORTA0_FUNC_UART0_RXD); system_set_port_mux(GPIO_PORT_A, GPIO_BIT_1, PORTA1_FUNC_UART0_TXD); uart_init(UART0, 1152); fr_uart_enableIrq(UART0, Uart_irq_erbfi); /* RC calibration start. Ensure the accuracy of sleep wake time */ pmu_calibration_start(PMU_CALI_SEL_RCLFOSC, LP_RC_CALIB_CNT); uart_putc_noint_no_wait(UART0, 'w'); NVIC_EnableIRQ(PMU_IRQn); } __attribute__((section("ram_code"))) void main_loop(void) { while(1) { if(ble_stack_schedule_allow()) { /*user code should be add here*/ /* schedule internal stack event */ ble_stack_schedule(); } GLOBAL_INT_DISABLE(); switch(ble_stack_sleep_check()) { case 2: { ble_stack_enter_sleep(); __jump_table.diag_port = 0x00008300; *(volatile uint32_t *)0x50000024 = 0xeeeeeeee; } break; default: break; } GLOBAL_INT_RESTORE(); ble_stack_schedule_backward(); } } /********************************************************************* * @fn proj_init * * @brief Main entrancy of user application. This function is called after BLE stack * is initialized, and all the application code will be executed from here. * In that case, application layer initializtion can be startd here. * * @param None. * * * @return None. */ void proj_init(void) { LOG_INFO(app_tag, "BLE Central\r\n"); // Application layer initialization, can included bond manager init, // advertising parameters init, scanning parameter init, GATT service adding, etc. simple_central_init(); } /********************************************************************* * @fn user_entry_before_ble_init * * @brief Code to be executed before BLE stack to be initialized. * Power mode configurations, PMU part driver interrupt enable, MCU * peripherals init, etc. * * @param None. * * * @return None. */ void user_main(void) { /* initialize log module */ log_init(); /* initialize PMU module at the beginning of this program */ pmu_sub_init(); patch_init(); /* set system clock */ system_set_clock(SYSTEM_CLOCK_SEL); /* set local BLE address. use the SOC unique ID as the address */ mac_addr_t mac_addr; system_get_unique_ID(mac_addr.addr); mac_addr.addr[5] = 0x20|0xC0; gap_address_set(&mac_addr, BLE_ADDR_TYPE_PRIVATE); /* configure ble stack capabilities */ ble_stack_configure(BLE_STACK_ENABLE_MESH, BLE_STACK_ENABLE_CONNECTIONS, BLE_STACK_RX_BUFFER_CNT, BLE_STACK_RX_BUFFER_SIZE, BLE_STACK_TX_BUFFER_CNT, BLE_STACK_TX_BUFFER_SIZE, BLE_STACK_ADV_BUFFER_SIZE, BLE_STACK_RETENTION_RAM_SIZE, BLE_STACK_KEY_STORAGE_OFFSET); /* initialize ble stack */ ble_stack_init(); /* initialize SMP */ gap_bond_manager_init(BLE_BONDING_INFO_SAVE_ADDR, BLE_REMOTE_SERVICE_SAVE_ADDR, 8, true); proj_init(); /* enter main loop */ main_loop(); } 详细解析以上代码
06-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值