Docker: go get from a private GitHub repo

后端 未结 4 1049
天涯浪人
天涯浪人 2021-02-19 06:17

I\'m trying to run a container that will expose a golang service from a package that I have on a private GitHub repo.

Since I am working with GCE, my starter image is g

4条回答
  •  隐瞒了意图╮
    2021-02-19 07:19

    In the newest version of golang (v1.11) there are now modules.

    To quote the source:

    A module is a collection of related Go packages that are versioned together as a single unit. Most often, a single version-control repository corresponds exactly to a single module.

    Using the latest version of golang will allow you to have dependencies that are in private repositories. Essentially by running the $ go mod vendor command will create a vendor directory locally for all external dependencies. Now making sure your docker image has Golang v1.11, you will update your Dockerfile with the following:

    WORKDIR /
    
    COPY . ./
    

提交回复
热议问题