githubnemo / CompileDaemon

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

go get doesn't not pull master branch with polling changes #60

Closed Christheoreo closed 3 years ago

Christheoreo commented 3 years ago

Hi there,

For ages I was trying to work out why the -polling option was causing this to crash out in docker.

I was using this docker file:


FROM golang:latest
EXPOSE 80

WORKDIR /usr/src/app/go-api

COPY . /usr/src/app/go-api

RUN go mod download

RUN go get github.com/githubnemo/CompileDaemon
RUN GO111MODULE=on
# RUN CompileDaemon
ENTRYPOINT CompileDaemon -build="go build main.go" -directory="." -polling -command=./main 

To which it ouputted the full list of options - not including -polling

" flag provided but not defined: -polling"

To fix this, I added @master to the go get command :


FROM golang:latest
EXPOSE 80

WORKDIR /usr/src/app/go-api

COPY . /usr/src/app/go-api

RUN go mod download

RUN go get github.com/githubnemo/CompileDaemon@master
RUN GO111MODULE=on
# RUN CompileDaemon
ENTRYPOINT CompileDaemon -build="go build main.go" -directory="." -polling -command=./main 

This now works!

This is an amazing project and I am very grateful for it - I just thought that this may come up for someone else!

I'm not sure why go get is behaving like this, but I assume it is a bug.

Full code example:

main.go


package main

import (
    "net/http"

    "github.com/labstack/echo/v4"
)

func main() {
    e := echo.New()
    e.GET("/", func(c echo.Context) error {
        return c.String(http.StatusOK, "Hello, dude!")
    })
    e.GET("/2", func(c echo.Context) error {
        return c.String(http.StatusOK, "Hello, my friend, again!")
    })

    e.Logger.Fatal(e.Start(":80"))
}

Dockerfile


FROM golang:latest
EXPOSE 80

WORKDIR /usr/src/app/go-api

COPY . /usr/src/app/go-api

RUN go mod download

RUN go get github.com/githubnemo/CompileDaemon
RUN GO111MODULE=on # not sure if needed
ENTRYPOINT CompileDaemon -build="go build main.go" -directory="." -polling -command=./main 

docker-compose.yml

services:
  go-api:
    build:
      context: .
    ports:
      - "8081:80"
    container_name: go-api
    tty: true
    volumes:
      - ./:/usr/src/app/go-api
githubnemo commented 3 years ago

Thanks for the heads up. Out of interest: you are using -polling because you are on Mac OS?

Christheoreo commented 3 years ago

Hey, I was using polling because Docker wasn't detecting any changes (using docker on windows)

ruddles commented 3 years ago

Thanks for this, just saved me a lot of head scratching, grabbing from master fixed the issue for me too.

bill-kerr commented 3 years ago

Thank you for posting this! Saved me a lot of time.

githubnemo commented 3 years ago

This should now be fixed since 1.3.0 is released.