Docker环境下使用CompileDaemon实现Golang热重载失效问题求助
Docker环境下使用CompileDaemon实现Golang热重载失效问题求助
大家好,我现在想在Docker环境下给Golang项目实现热重载功能,已经编写了对应的Dockerfile和docker-compose.yml配置,但修改本地代码后容器完全没有触发重载反应,想请教下各位大佬哪里出问题了?
我的Dockerfile.dev内容如下:
# Go Version FROM golang:latest # Environment variables which CompileDaemon requires to run ENV PROJECT_DIR=/app \ GO111MODULE=on \ CGO_ENABLED=0 # Basic setup of the container RUN mkdir /app COPY .. /app WORKDIR /app # Get CompileDaemon RUN go get github.com/githubnemo/CompileDaemon RUN go install github.com/githubnemo/CompileDaemon # The build flag sets how to build after a change has been detected in the source code # The command flag sets how to run the app after it has been built ENTRYPOINT CompileDaemon -build="go build -o api" -command="./api"
对应的docker-compose.yml配置:
version: '3.8' name: live-reload-example services: api: container_name: api build: context: . dockerfile: Dockerfile.dev ports: - 8501:8501 volumes: - ./:/app
目前的问题是,当我修改本地的Go源码文件后,容器内的服务完全没有重新构建、运行的迹象,热重载功能完全没生效,希望能得到大家的排查建议!
备注:内容来源于stack exchange,提问作者Mehrdad Masoumi
相关产品推荐
相关产品推荐

