【发布时间】:2021-06-21 19:40:19
【问题描述】:
我尝试按照official documentation instructions 创建和部署 Oracle 云功能。我可以使用 java runtime 创建和部署,但是当我部署 go runtime 时总是返回错误。
我尝试在 Oracle Cloud Shell 中使用此命令初始化 Go 函数:
fn init --runtime go hello-go
然后我尝试部署它
fn -v deploy --app test
但它返回如下错误:
Deploying hello-go to app: test
Bumped to version 0.0.7
Building image bom.ocir.io/bmptwl2psusa/repo/hello-go:0.0.7
FN_REGISTRY: bom.ocir.io/bmptwl2psusa/repo
Current Context: ap-mumbai-1
Sending build context to Docker daemon 5.632kB
Step 1/10 : FROM fnproject/go:dev as build-stage
---> 96c8fb94a8e1
Step 2/10 : WORKDIR /function
---> Using cache
---> 8961dd299ec1
Step 3/10 : WORKDIR /go/src/func/
---> Using cache
---> 5a4c2c6e13f1
Step 4/10 : ENV GO111MODULE=on
---> Using cache
---> 22022ff2fcf8
Step 5/10 : COPY . .
---> 714622a6ff03
Step 6/10 : RUN cd /go/src/func/ && go build -o func
---> Running in 39fedbc476f4
build func: cannot find module for path github.com/fnproject/fdk-go
The command '/bin/sh -c cd /go/src/func/ && go build -o func' returned a non-zero code: 1
Fn: error running docker build: exit status 1
当我用fn init --runtime java hello-java命令使用java运行时,它已经成功部署,为什么使用go总是失败?
我尝试在hello-go 目录中运行go build -o func,但它返回了:
go: finding module for package github.com/fnproject/fdk-go
go: writing stat cache: mkdir /usr/share/gocode/pkg: permission denied
go: downloading github.com/fnproject/fdk-go v0.0.3
func.go:10:2: mkdir /usr/share/gocode/pkg: permission denied
我知道这是因为/usr/share/gocode/ 目录在 root 用户下,但我不知道如何更改该文件夹的权限,因为 Oracle Cloud Shell 不能使用 root 用户或 sudo。 (基于this answer)
如果我使用真正的 VM shell 或本地 shell/终端,也许我可以做到,但我想使用 Oracle Cloud Shell,因为我只是按照建议我使用 Oracle Cloud Shell 的官方说明进行操作,那么如何使用使用 Oracle Cloud Shell 去运行时?
大部分官方文档只给出了使用Java运行时的例子,这让我在使用go时变得偏执。
【问题讨论】:
标签: function go oracle-cloud-infrastructure oracle-cloud-functions oracle-cloud-shell