Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Failure all dirs lacked any go code when pre-loading vendor/ directory with dep ensure in Docker Build #965

Closed
maxmeyer opened this issue Aug 7, 2017 · 3 comments

Comments

@maxmeyer
Copy link

maxmeyer commented Aug 7, 2017

What version of Go (go version) and dep (git describe --tags) are you using?

Go: 1.8.3
Dep: v0.2.1-6-gc1aba4d

What dep command did you run?

I would like to use dep inside a build container. I also have vendor/ set up by dep in the project root and there's also no entry in the .dockerignore-file preventing the directory to be passed to the "Docker"-daemon. Those are the example Dockerfiles for the build environment.

  1. Naive approach

    FROM golang:1.8-alpine
    
    RUN go get -u github.com/golang/dep/cmd/dep
    
    WORKDIR /go/src/github.com/example/project
    
    COPY . .
    
    RUN dep ensure
    RUN make
    

    The problem here is, that dep ensure is needed to run every time, when there are code changes to . which takes around 10 mins. Even using a caching HTTP proxy will only help to reduce that costs for the infrastructure where the proxy is enrolled.

  2. Better approach - which fails

    FROM golang:1.8-alpine
    
    RUN go get -u github.com/golang/dep/cmd/dep
    
    WORKDIR /go/src/github.com/example/project
    
    COPY Gopkg.* ./
    RUN dep ensure
    
    COPY . .  
    RUN dep ensure
    
    RUN make
    

    This fails with all dirs lacked any go code. You see this kind of pattern in Ruby-applications to speed up the docker build. This makes use of "Docker"'s inbuild caching mechanism. Adding a more or less empty main.go does not help either.

What did you expect to see?

Install packages without any error

What did you see instead?

all dirs lacked any go code
@sdboyer
Copy link
Member

sdboyer commented Aug 7, 2017

hi! i believe that #796 describes exactly what you're looking for, and - as of Friday's merge - you can achieve this with dep ensure -vendor-only 😄

@maxmeyer
Copy link
Author

maxmeyer commented Aug 8, 2017

Sounds great! What about deb ensure -local to prevent any network communication?

@sdboyer
Copy link
Member

sdboyer commented Aug 10, 2017

that'd be what something like #945 is about 😄

@sdboyer sdboyer closed this as completed Aug 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants