githubnemo / CompileDaemon

Very simple compile daemon for Go
BSD 2-Clause "Simplified" License
1.61k stars 153 forks source link

CompileDaemon does not work with Docker on Vagrant. #50

Closed vuongabc92 closed 3 years ago

vuongabc92 commented 4 years ago

Hello,

Please help, I don't know where is the issue but after changing file CompileDaemon does not re-compile go application. Currently, I'm using Windows, I don't want to use docker desktop for Windows so I install docker on Vagrant. Here is my Dockerfile-local

FROM golang:alpine

# Set necessary environmet variables needed for our image
ENV GO111MODULE=on \
    CGO_ENABLED=0 \
    GOOS=linux \
    GOARCH=amd64

WORKDIR /build
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .

RUN apk add git
RUN go get github.com/githubnemo/CompileDaemon
ENTRYPOINT CompileDaemon --build="go build -o bin cmd/apiserver/server.go" --command="./bin/server"

And this is docker-compose file

version: '3'
services:
  api-server:
    build:
      context: ./
      dockerfile: Dockerfile-${ENV}
    image: api_server:tag
    container_name: api-server
    hostname: api-server
    restart: always
    volumes:
      - ./:/build
    ports:
      - 8080:8080

I missed something, didn't I? Or It's a Vagrant problem (Vagrant does not forward file changing event to docker).

Thank you very much for any help and sorry for my English.

githubnemo commented 3 years ago

It is indeed a problem with Vagrant. This user had a very similar issue. The underlying file system that connects host and VM does not propagate the changes properly. The user suggested to use an rsync plugin that syncs files instead.