I\'m trying to build a docker with a local package but get the error \'import path does not begin with hostname\'. If my understanding is correct, my Dockerfile should be ju
Try :
FROM golang:latest
RUN mkdir /go/src/app
WORKDIR /go/src/app
ADD ./HelloWorld.go ./
RUN go get
RUN go build -o main .
CMD ["/go/src/app/main"]
The application is built inside the docker container and you need to have your dependencies available when building.
golang:onbuild
gives compact Dockerfiles for simple cases but it will not fetch your dependencies.
You can write your own Dockerfile with the steps needed to build your application. Depending on how your project looks you could use something like this:
FROM golang:1.6
ADD . /go/src/yourapplication
RUN go get github.com/jadekler/git-go-websiteskeleton
RUN go install yourapplication
ENTRYPOINT /go/bin/yourapplication
EXPOSE 8080
This adds your source and your dependency into the container, builds your application, starts it, and exposes it under port 8080.