Closed boppy closed 4 years ago
Additional: If I modify the Dockerfile to be the following, it continues with compiling, but stops with:
The command '/bin/sh -c CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o streamhut cmd/streamhut/main.go' returned a non-zero code: 2
Dockerfile:
FROM golang:1.12rc1-alpine3.9
RUN apk --no-cache add gcc musl-dev ca-certificates git
# ^ new
COPY . /go/src/github.com/streamhut/streamhut
WORKDIR /go/src/github.com/streamhut/streamhut
RUN go get github.com/patrickmn/go-cache
# ^ full line is new
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o streamhut cmd/streamhut/main.go
CMD ["./streamhut", "server"]
@boppy that is bizarre since go-cache is definitely in the vendor directory. You could try re-downloading the dependencies right before the build command:
FROM golang:1.12rc1-alpine3.9
RUN apk --no-cache add gcc musl-dev ca-certificates git
COPY . /go/src/github.com/streamhut/streamhut
WORKDIR /go/src/github.com/streamhut/streamhut
RUN GO111MODULE=on go mod download
RUN GO111MODULE=on go mod vendor
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o streamhut cmd/streamhut/main.go
CMD ["./streamhut", "server"]
download+vendor does the trick!
But without downloading I still get the same error with the current git version.
There was an issue with the .gitignore file causing some of the dependencies in the vendor directory to be ignored. It's resolved now and this should work. I tested it on a fresh git clone:
Dockerfile
FROM golang:1.12rc1-alpine3.9
RUN apk --no-cache add gcc musl-dev ca-certificates
COPY . /go/src/github.com/streamhut/streamhut
WORKDIR /go/src/github.com/streamhut/streamhut
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o streamhut cmd/streamhut/main.go
CMD ["./streamhut", "server"]
Build
docker build -t streamhut/streamhut .
Run
docker run -p 8080:8080 -p 1337:1337 streamhut/streamhut:latest
Closing the issue but let me know if it doesn't work still.
Building of the supplied Dockerfile results in:
Full Log at https://gist.github.com/boppy/ff44e290d663eda4c31d72dd015a571e