Docker build context

I have a Golang program that is structure like this:

base-folder
| – go.mod
| – go.sum
|-- cmd
|-- pkgs
|-- pkg1
|-- pkg2
|-- models
|-- model.go
|–service
|-- app
|
|-- Dockerfile
| main.go
| other.go

In main.go, it imports packages from “base-folder/pkgs/pkg1”, "base-folder/pkgs/pkg2, and “base-folder/model”.

Everything compiles fine with a regular go build statement.

When I try and run the docker build from the /app directory - the Dockerfile cannot find the go.mod file to pull in th imports.

If I move the Dockerfile to the same level as the go.mod file, it cannot find other folders.

If I move the go.mod file into the /app folder, the imports happen, but the /pkg /model folders cannot be found in the context.

What is the appropriate to structure/call the docker build command when source files are in different folders?