fn quick start

简介:

fn quick start

Fn is an event-driven, open source, functions-as-a-service compute platform that you can run anywhere. Some of it's key features:

  • Write once

    • Any language
    • AWS Lambda format supported
  • Run anywhere

    • Public, private and hybrid cloud
    • Import functions directly from Lambda and run them wherever you want
  • Easy to use for developers
  • Easy to manage for operators
  • Written in Go
  • Simple yet powerful extensibility

1.安装fn

brew install fn

2. 升级docker

docker version

Client:
 Version:      17.09.0-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:40:09 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.09.0-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:45:38 2017
 OS/Arch:      linux/amd64
 Experimental: false

3. 登录docker hub

docker login

Username (feuyeux@gmail.com): feuyeux
Password:
Login Succeeded

4. 启动fn服务

 fn start
        ______
       / ____/___
      / /_  / __ \
     / __/ / / / /
    /_/   /_/ /_/
        v0.3.141

5. 撰写函数

mkdir hello
cd hello
vim func.go
package main

import (
  "fmt"
)

func main() {
  fmt.Println("Hello from Fn!")
}

6. 创建应用

fn init

        ______
       / ____/___
      / /_  / __ \
     / __/ / / / /
    /_/   /_/ /_/

Found go function, assuming go runtime.
func.yaml created.

7. 打包应用

fn run                                                                    

Building image feuyeux/hello:0.0.1
Sending build context to Docker daemon  4.096kB
Step 1/8 : FROM funcy/go:dev as build-stage
 ---> 4cccab7fc828
Step 2/8 : WORKDIR /function
 ---> Using cache
 ---> ba44eaaa14da
Step 3/8 : ADD . /go/src/func/
 ---> c6480ae51b4f
Step 4/8 : RUN cd /go/src/func/ && go build -o func
 ---> Running in ac0d2269aebb
 ---> 7ed8e8c8c7ba
Removing intermediate container ac0d2269aebb
Step 5/8 : FROM funcy/go
 ---> 573e8a7edc05
Step 6/8 : WORKDIR /function
 ---> Using cache
 ---> 00809f3fee14
Step 7/8 : COPY --from=build-stage /go/src/func/func /function/
 ---> Using cache
 ---> ee31e804adca
Step 8/8 : ENTRYPOINT ./func
 ---> Using cache
 ---> 5f32eff9e328
Successfully built 5f32eff9e328
Successfully tagged feuyeux/hello:0.0.1
Hello from Fn!

8. 部署应用

fn deploy --app myapp

Deploying hello to app: myapp at path: /hello
Bumped to version 0.0.2
Building image feuyeux/hello:0.0.2
Sending build context to Docker daemon  4.096kB
Step 1/8 : FROM funcy/go:dev as build-stage
 ---> 4cccab7fc828
Step 2/8 : WORKDIR /function
 ---> Using cache
 ---> ba44eaaa14da
Step 3/8 : ADD . /go/src/func/
 ---> 88ec5ca237e5
Step 4/8 : RUN cd /go/src/func/ && go build -o func
 ---> Running in e2247c834266
 ---> c787e9416655
Removing intermediate container e2247c834266
Step 5/8 : FROM funcy/go
 ---> 573e8a7edc05
Step 6/8 : WORKDIR /function
 ---> Using cache
 ---> 00809f3fee14
Step 7/8 : COPY --from=build-stage /go/src/func/func /function/
 ---> Using cache
 ---> ee31e804adca
Step 8/8 : ENTRYPOINT ./func
 ---> Using cache
 ---> 5f32eff9e328
Successfully built 5f32eff9e328
Successfully tagged feuyeux/hello:0.0.2
Pushing feuyeux/hello:0.0.2 to docker registry...The push refers to a repository [docker.io/feuyeux/hello]
b34434bfd239: Pushed
3d098239d19c: Pushed
e9474866f7d4: Pushed
c0e205d473e9: Pushed
0.0.2: digest: sha256:b88635814d7935e7a505133b167c3937663fa73344579790dea60877c13f5491 size: 1154
Updating route /hello using image feuyeux/hello:0.0.2...

9. 测试应用

curl http://localhost:8080/r/myapp/hello
Hello from Fn!
fn call myapp /hello
Hello from Fn!
目录
相关文章
|
SQL Shell 网络安全
CISP-PTE综合靶机-WinServer2003学习
CISP-PTE综合靶机-WinServer2003学习
5644 0
|
11天前
|
人工智能 开发工具 iOS开发
Claude Code 新手完全上手指南:安装、国产模型配置与常用命令全解
Claude Code 是一款运行在终端环境中的 AI 编程助手,能够直接在命令行中完成代码生成、项目分析、文件修改、命令执行、Git 管理等开发全流程工作。它最大的特点是**任务驱动、终端原生、轻量高效、多模型兼容**,无需图形界面、不依赖 IDE 插件,能够深度融入开发者日常工作流。
3293 9
|
3天前
|
人工智能 自然语言处理 文字识别
阿里云百炼Qwen3.7-Max简介:能力、优势、支持订阅计划参考
Qwen3.7-Max是阿里云百炼面向智能体时代推出的新一代旗舰模型,对标GPT-5.5、Claude Opus 4.7等闭源旗舰。该模型支持百万级token上下文窗口,具备顶级推理能力、多模态搜索与视觉理解增强、流式输出低延迟响应等核心优势,覆盖编程、办公、长周期自主执行等复杂场景。同时支持OpenAI接口兼容,便于系统快速迁移。用户可通过Token Plan团队或节省计划等订阅方式灵活调用,适合企业级高要求场景使用。
1648 5
阿里云百炼Qwen3.7-Max简介:能力、优势、支持订阅计划参考
|
14天前
|
Shell API 开发工具
Claude Code 快速上手指南(新手友好版)
AI编程工具卷疯啦!Claude Code凭借任务驱动+终端原生的特性,成了开发者的效率搭子。本文从安装、登录、切换国产模型到常用命令,手把手带新手快速上手,全程避坑,30分钟独立用起来。
3339 23
|
7天前
|
人工智能 Linux BI
国内用 Claude Code 终于不用翻墙了:一行命令搞定,自动接 DeepSeek
JeecgBoot AI专题研究 一键脚本:Claude Code + JeecgBoot Skills + DeepSeek 全平台接入 一行命令装好 Claude Code + JeecgBoot Skills + DeepSeek 接入,无需翻墙使用 Claude Code,支持 Wind
2381 4
国内用 Claude Code 终于不用翻墙了:一行命令搞定,自动接 DeepSeek
|
26天前
|
人工智能 JSON 供应链
畅用7个月无影 JVS Claw |手把手教你把JVS改造成「科研与产业地理情报可视化大师」
LucianaiB分享零成本畅用JVS Claw教程(学生认证享7个月使用权),并开源GeoMind项目——将JVS改造为科研与产业地理情报可视化AI助手,支持飞书文档解析、地理编码与腾讯地图可视化,助力产业关系图谱构建。
23599 15
畅用7个月无影 JVS Claw |手把手教你把JVS改造成「科研与产业地理情报可视化大师」
|
13天前
|
人工智能 JSON BI
DeepSeek V4-Pro 接入 Claude Code 完全实战:体验、测试与关键避坑指南
Claude Code 作为当前主流的 AI 编程辅助工具,凭借强大的代码理解、工程执行与自动化能力深受开发者喜爱,但原生模型的使用成本相对较高。为了在保持能力的同时进一步降低开销,不少开发者开始寻找兼容度高、价格更友好的替代模型。DeepSeek V4 系列的发布带来了新的选择,该系列包含 V4-Pro 与 V4-Flash 两款模型,并提供了与 Anthropic 完全兼容的 API 接口,理论上只需简单修改配置,即可让 Claude Code 无缝切换为 DeepSeek 引擎。
2864 3
|
5天前
|
人工智能 自然语言处理 安全
Claude Code 全攻略:命令大全+三种模式+记忆体系+实战工作流完整手册
Claude Code 是当前最流行的终端级 AI 编程助手,能够直接在命令行中完成代码生成、项目理解、文件修改、命令执行、错误修复等全流程开发工作。它不依赖图形界面、不占用额外资源,却能深度理解项目结构,自动生成规范代码,大幅提升研发效率。
945 2