Go-使用CompileDaemon进行Docker自动重载

I am working on trying to improve my development environment using Docker and Go but I am struggling to get auto reloading in my containers working when there is a file change. I am on Windows running Docker Desktop version 18.09.1 if that matters.

I am using CompileDaemon for reloading and my DockerFile is defined as follows

FROM golang:1.11-alpine
RUN apk add --no-cache ca-certificates git
RUN go get github.com/githubnemo/CompileDaemon
WORKDIR /go/src/github.com/testrepo/app
COPY . .
EXPOSE 8080

ENTRYPOINT CompileDaemon -log-prefix=false -directory="." -build="go build /go/src/github.com/testrepo/app/cmd/api/main.go" -command="/go/src/github.com/testrepo/app/main" 

My project structure follows

  • app
    • api
      • main.go

In my docker-compose file I have the correct volumes set and the files are being updated in my container on when I make changes locally.

The application is also started correctly using CompileDaemon on its first load, its just not ever updated on file changes.

On first load I see...

Running build command!
Build ok.
Restarting the given command.

Then any changes I make are not resulting in a restart even though I can connect to the container and see that the changes are reflected in the expected files.

Thanks for any help or ideas!