title: Golang Dockerfile : Unable to find packages in docker build but runs normally
body: <p>I have the following dockerfile setup for a multistage build for my golang microservice project</p>
  
  <pre><code>FROM golang:alpine as builder
  
  RUN apk --no-cache add git
  
  WORKDIR /app/vessel-service
  
  COPY . .
  
  RUN go mod download
  RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o vessel-service
  
  # Second Stage
  ...
  </code></pre>
  
  <p>I have the following imports in my main.go</p>
  
  <pre><code>import (
    "context"
    "errors"
    "fmt"
  
    pb "github.com/thededlier/go-micro-shippy/vessel-service/proto/vessel"
    micro "github.com/micro/go-micro"
  )
  </code></pre>
  
  <p>where the vessel-service one is for the current project.</p>
  
  <p>On running <code>docker build -t vessel-service .</code> I get the following error </p>
  
  <pre><code>Step 5/12 : RUN go mod download
   ---&gt; Running in 1d0121039462
  warning: pattern "all" matched no module dependencies
  Removing intermediate container 1d0121039462
   ---&gt; b66add421d26
  Step 6/12 : RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o vessel-service
   ---&gt; Running in ef50eff44a3b
  main.go:9:3: cannot find package "github.com/micro/go-micro" in any of:
    /usr/local/go/src/github.com/micro/go-micro (from $GOROOT)
    /go/src/github.com/micro/go-micro (from $GOPATH)
  main.go:8:3: cannot find package "github.com/thededlier/go-micro-shippy/vessel-service/proto/vessel" in any of:
    /usr/local/go/src/github.com/thededlier/go-micro-shippy/vessel-service/proto/vessel (from $GOROOT)
    /go/src/github.com/thededlier/go-micro-shippy/vessel-service/proto/vessel (from $GOPATH)
  </code></pre>
  
  <p>But I do have <code>~/go/src/github.com/micro/go-micro</code>. On trying to just directly run main.go, it runs without any issues. </p>
  
  <p>Is this an issue with my environment setup or is there something more to this?</p>
  
  <p>Here's a summary of my <code>go.mod</code></p>
  
  <pre><code>    module github.com/thededlier/go-micro-shippy
  
      go 1.12
  
      require (
        ...
        github.com/micro/go-micro v1.1.0
        ...
      )
      replace github.com/testcontainers/testcontainer-go =&gt; github.com/testcontainers/testcontainers-go v0.0.0-20190108154635-47c0da630f72
  
      replace sourcegraph.com/sourcegraph/go-diff =&gt; github.com/sourcegraph/go-diff v0.5.1
  
      replace github.com/golang/lint =&gt; golang.org/x/lint v0.0.0-20190409202823-959b441ac422
  
      replace github.com/Sirupsen/logrus =&gt; github.com/sirupsen/logrus v1.4.1
  </code></pre>