title: main.go: no required module provides package
body: <p>My Go module, stored in GitHub, successfully compiles locally; however, if I try to do it via docker, even locally in the same folder, I get an error complaining that my local package does not exist, for every local import in a subfolder:</p>
  <pre><code>=&gt; ERROR [build 7/7] RUN go build -o myrepo-test .                                                                                                                                                                                                                          0.6s 
  ------
   &gt; [build 7/7] RUN go build -o myrepo-test .:
  #14 0.535 main.go:10:2: no required module provides package github.com/myuser/myrepo-test/common; to add it:
  #14 0.535       go get github.com/myuser/myrepo-test/common
  #14 0.535 main.go:13:2: no required module provides package github.com/myuser/myrepo-test/scraper/data/process; to add it:
  #14 0.535       go get github.com/myuser/myrepo-test/scraper/data/process
  (....)
  </code></pre>
  <p>Here is my <code>go.mod</code>:</p>
  <pre><code>module github.com/myuser/myrepo-test
  
  go 1.16
  </code></pre>
  <p>And the docker file:</p>
  <pre><code># use alpine due to its small footprint
  FROM golang:1.16-buster AS build
  
  WORKDIR /app
  
  # download the required Go dependencies
  COPY go.mod ./
  COPY go.sum ./
  RUN go mod download
  
  COPY *.go ./
  
  # FAIL
  RUN go build -o myrepo-test .
  
  ##########
  # Deploy #
  ##########
  
  FROM gcr.io/distroless/base-debian10
  
  WORKDIR /
  
  COPY --from=build /myrepo-test /myrepo-test
  
  USER nonroot:nonroot
  
  ENTRYPOINT [&quot;/myrepo-test&quot;]
  
  CMD [&quot;/myrepo-test&quot;]
  </code></pre>