dsgoj7457 2017-12-03 13:15
浏览 103
已采纳

docker内的golang错误

I get a strange error in docker when building my go app:

./main.go:31:9: cannot use db (type *"github.com/khwerhahn/somerepo/vendor/github.com/jinzhu/gorm".DB) as type *"app/vendor/github.com/jinzhu/gorm".DB in argument to Migrate  
The command '/bin/sh -c go-wrapper install' returned a non-zero code: 2

Could somebody hint me into the right direction, because locally the app runs just fine. Its just inside the docker container. I use glide to manage dependencies.

Dockerfile:

FROM golang:1.9
WORKDIR /go/src/app
COPY . .
RUN go-wrapper download
RUN go-wrapper install

CMD ["go-wrapper", "run"]

//// Edit This is how my structure looks. Glide manages the vendor folder. The docker build does the rest.

enter image description here

  • 写回答

1条回答 默认 最新

  • dongzhonggua4229 2017-12-04 16:56
    关注

    It's because go get is called by go-wrapper download. This fetches the dependencies from the remote instead of looking in the vendor folder.

    If your libraries are already vendored and the code is in the vendor folder, all you should have to do is go run or go install.

    and why do you need go-wrapper when you can just do.

    RUN glide install
    RUN go install
    WORKDIR "../bin"
    RUN myapp
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码