You can not run a Go project using GVM and an observer in a Docker container (GOPATH can not be configured correctly)

I've been experiencing some problems when trying to run a Docker image that creates a Go project.

Any help would be much appreciated, since I've been stuck in this for days. I'm not an expert on Docker, so I might be making a rookie mistake.

I'm trying to share a volume on my machine with my Go project, then I install Go 1.9 in the Docker container and use GVM to be able to change its version easily later. Also, I am using this monitor: / canthefason / go-watcher to automatically rebuild the Go project every time there is a change to a file.

But when I docker-compose up My container, the observer can not build the project, he tells me Unable to load the package: finance package: no files Go in / go / src / finance.

The root folder of the project on my machine (/to finance) In fact, it does not contain any Go files (the Go files are in subfolders of this root folder), so the structure of the project looks like this:

    - finances
- build
- package
- Dockerfile
- entrypoint.sh
- cmd
- finances
- main.go
- internal
- other .go files
- docker-compose.yml

In my Dockerfile I declare a

ENV GOPATH / go

To use it as my GOPATH, but it does not work.
I have also tried to EXECUTE GOPATH export = / go just before the last lines of the Docker file, but it does not work either.

When my container starts to work, GOPATH is always configured to GOPATH = "/ root / .gvm / pkgsets / go1.9 / global" and I discovered that this is due to GVM, but I do not want to change the default GOPATH, I want GOPATH = / go and I suspect that the observer can not build the Go project because of this discrepancy.

Basically, I can not configure my GOPATH because GVM always sets it to its default route, and that's probably why the observer can not compile and run my Go project.

Here is my Dockerfile:

                FROM buildpack-deps: jessie-scm
MAINTAINER Can Yucel "can.yucel@gmail.com"

EXECUTE apt-get update && apt-get install -y --no-install-recommends 
g ++ 
gcc
libc6-dev 
do 
pkg-config 
bison
&& rm -rf / var / lib / apt / lists / *

SHELL ["/bin/bash", "-c"]

    ENV GO_VERSION 1.9

RUN curl -s -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer | swipe

RUN . /root/.gvm/scripts/gvm&& 
gvm install go $ {GO_VERSION} -B && 
gvm use go $ {GO_VERSION}

ENV WATCHER_VERSION 0.2.4

ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 /root/.gvm/bin/watcher

EXECUTE chmod + x /root/.gvm/bin/watcher

# Apparently this is useless  /
ENV GOPATH / go

WORKDIR / go / src / finance

ADD ./build/package/entrypoint.sh / go / src / finance / cmd / finance

EXECUTE chmod + x / go / src / finance / cmd / finance.

# This does not seem to work!  /
Execute export GOPATH = $ {GOPATH}

ENTRY POINT ["/entrypoint.sh"]
    CMD ["watcher"]