douxu4610 2015-09-21 03:32
浏览 100
已采纳

Docker-compose golang-无可构建源

I've followed a couple of tutorials and am having trouble figuring out what i've done wrong. I suspect its a very basic principal but that said as i'm new to both GoLang and docker-compose i'm not 100% sure which is my problem.

I'm running the golang:build docker image which just retrieves a couple github repositories.

Any help would be much appreciated.

The error is as follows:

+ exec go get -v -d
can't load package: package app: no buildable Go source files in /go/src/app
Service 'ddd' failed to build: The command '/bin/sh -c go-wrapper download' returned a non-zero code: 1

The Docker-Compose file looks like this

ddd:
  build: ./goSvc
  working_dir: /go/src/
  command: go run main.go
  volumes:
    - ./goSvc/src/main.go:/go/src/main.go
    - ./goSvc/src/ddd:/go/src/ddd
  ports:
    - 8080:8080
  environment:
    - DB_NAME=rnse
    - DEBUG=true

Go project structure

root
  goSvc
    pkg
    src
      ddd
        internal
          logic
        ...myGoFiles
      github.com
      main.go
    Dockerfile

Edit: Including docker file for golang:

FROM golang:onbuild
RUN go get github.com/gorilla/mux
RUN go get github.com/lib/pq
EXPOSE 8080
  • 写回答

1条回答 默认 最新

  • dongtuoao7987 2015-09-22 08:51
    关注

    Image you used is used to automatically build Go app when building initial image.

    Have a look at it's Dockerfile. There is ONBUILD COPY . /go/src/app statement.

    So you can either locate Dockerfile where main.go is located or use image without ONBUILD trigger and then run go run manually/with docker-compose.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题