In my Golang/gin project i have a dockerfile. This docker file looks like this
FROM golang:latest
RUN mkdir -p /go/src/myAppName
ADD . /go/src/myAppName
WORKDIR /go/src/myAppName
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN go get -d -v ./...
RUN go install -v ./...
RUN go get github.com/pilu/fresh
EXPOSE 8080
CMD ["fresh"]
When I run the command docker build . --tag=myAppName:dev
in the root directory of the project where the Dockerfile is located, it runs fine untill it wants to install the packages with the go get -d -v ./...
command.
My project has a lot of different packages located in the project itself, so when it tries to import those it tells me the following:
package myAppName/app: unrecognised import path "myAppName/app" (import path does not begin with hostname).
I have read this question and promptly set the $GOPATH
in my Dockerfile.
I also read this question and tried building the project the manual way without fresh and their method of not setting the GOPATH at all but doing it through the WORKDIR
command.
Finally I tried using the go-wrapper
commands, but these seem to not be available when i try to use them, resulting in the error command not found: go-wrapper
Unfortunately neither of these work, thus my question.
Any help or pointers in the right direction are much appreciated.