I have an issue getting my local build to run as well as getting my Dockerfile configured.
My project structure looks like:
project
- cmd
main.go
- internal
- app
app.go
Dockerfile
So, in main.go
I say
import (
"project/internal/app"
)
Then, when I say go build
I can run locally perfectly.
However, in my Dockerfile I say
FROM golang
ENV GOPATH /go/src/github.com/project
COPY . /go/src/github.com/project
WORKDIR /go/src/github.com/project
RUN make linux
And I get the issue:
cmd/main.go:4:2: cannot find package "Slaxtract/internal/app" in any of:
/usr/local/go/src/project/internal/app (from $GOROOT)
/go/src/github.com/project/src/project/internal/app (from $GOPATH)
Why is Docker adding src
to the GOPATH? And how can I configure it to look in the right spot?
If I change my main.go
to be a relative path I can hack a fix - but then I can't run locally as I get
main.go:4:2: local import "../internal/app" in non-local package
Any and all help would be really appreciated.