我們正在嘗試將 golang 二進制文件部署到 cf。例如 main.exe 與 mainfest 文件一起位于 /deploy/ 文件夾中注意:還觀察到,如果我們推送整個項目應用程序,那么它就可以工作。但是如果我們嘗試只推送二進制文件,那么我們會得到以下錯誤清單文件包含以下信息 applications: - name: test-app command: test-app env: GO_INSTALL_PACKAGE_SPEC: ./**ERROR** To use go native vendoring set the $GOPACKAGENAME environment variable to your app's package name **ERROR** Unable to determine import path: GOPACKAGENAME unset添加 GOPACKAGENAME: main 后,因為 main.exe 是我們的二進制名稱,我們在下面收到以下錯誤 Failed to compile droplet: Failed to run finalize script: exit status 12 Cell 507b6e9c-c5c5-4685-9a71-d7cc1c876f5a stopping instance 6a92ff73-76ec-4baf-8a3e-54b54cfa307eBuildpackCompileFailed - App staging failed in the buildpack compile phase
1 回答

忽然笑
TA貢獻1806條經驗 獲得超5個贊
對于上述問題:
首先我們必須使用以下命令構建(使用 make 文件)
GOOS="linux" go build main.go
然后將該主二進制文件復制到 /deploy 文件夾
然后清單文件在部署文件夾中
applications:
- name: test-app
command: ./main
stack: cflinuxfs3
buildpacks:
- https://github.com/cloudfoundry/binary-buildpack.git
然后推送到cf
cf push -f ./manifest-template.yml
- 1 回答
- 0 關注
- 97 瀏覽
添加回答
舉報
0/150
提交
取消