cameradar: Build failure: `curl version is too low`

Hy…
I when getting image from dockerfile clone source code github The program encounters the following problem

Context

Please select one:

  • [ ✅ ] I use my own build of the docker image

Please select one:

  • [ ✅ ] I use the latest commit of the master branch

Environment

My operating system:

  • [ ✅ ] Linux

OS version: <Ubuntu 22.10>

Issue

#0 27.23 # github.com/Ullaakut/go-curl #0 27.23 In file included from /go/pkg/mod/github.com/!ullaakut/go-curl@v0.0.0-20190525093431-597e157bbffd/const.go:5: #0 27.23 ./compat.h:423:2: error: #error your version is TOOOOOOOO low #0 27.23 423 | #error your version is TOOOOOOOO low #0 27.23 | ^~~~~

What was expected

<expected behavior>

What happened

when clone project from github and builde dockerfile without changing the source code dockerfile <observed behavior>

Logs

sudo docker build -t test:001 .

...
#0 15.33 go: downloading golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
#0 15.40 go: downloading golang.org/x/text v0.3.0
#0 15.40 go: downloading github.com/fatih/color v1.7.0
#0 17.12 go: downloading github.com/mattn/go-isatty v0.0.8
#0 17.12 go: downloading github.com/mattn/go-colorable v0.1.2
#0 27.23 # github.com/Ullaakut/go-curl
#0 27.23 In file included from /go/pkg/mod/github.com/!ullaakut/go-curl@v0.0.0-20190525093431-597e157bbffd/const.go:5
#0 27.23 ./compat.h:423:2: error: #error your version is TOOOOOOOO low
#0 27.23   423 | #error your version is TOOOOOOOO low
#0 27.23       |  ^~~~~
------
Dockerfile:17
--------------------
  15 |     ENV GO111MODULE=on
  16 |     RUN go version
  17 | >>> RUN go build -o cameradar
  18 |     
  19 |     # Final stage
--------------------
ERROR: failed to solve: process "/bin/sh -c go build -o cameradar" did not complete successfully: exit code: 1

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 17 (6 by maintainers)

Most upvoted comments

OK @Ullaakut It’s an incompatible version requirement between go-curl and golang version. I succeed to build with a previous version like this one : FROM golang:1.16-alpine3.13 AS build-env

Maybe we need to find the latest version that compile correctly. But this one seems to do the job. I tried really old ones that crash for some other reasons…

@dordyan I had to modify your Dockerfile source code in order to get it working for me. It will be found to be more simplistic, but running it this way allowed the achievement of a successful build, where otherwise it proved unsuccessful.

FROM golang:alpine3.13
RUN mkdir -p /go
RUN mkdir -p /app
COPY . /go/src/github.com/Ullaakut/cameradar
COPY ./dictionaries /app/dictionaries

WORKDIR /go/src/github.com/Ullaakut/cameradar/cmd/cameradar

RUN apk upgrade && \
    apk add nmap \
    nmap-nselibs \
    nmap-scripts \
    gcc \
    libc-dev \
    git \
    curl==7.79.1-r3 \
    curl-dev==7.79.1-r3

ENV GO111MODULE=on
RUN go version
RUN go build -o cameradar

# Necessary to install curl v7.64.0-r3.
# Fix for https://github.com/Ullaakut/cameradar/issues/247
RUN sed -i 's/v3.13/v3.9/g' /etc/apk/repositories

RUN apk add --no-cache nmap \
    nmap-nselibs \
    nmap-scripts \
    curl-dev==7.64.0-r5 \
    curl==7.64.0-r5

WORKDIR /app
RUN cp /go/src/github.com/Ullaakut/cameradar/cmd/cameradar /app/cameradar

ENV CAMERADAR_CUSTOM_ROUTES="/app/dictionaries/routes"
ENV CAMERADAR_CUSTOM_CREDENTIALS="/app/dictionaries/credentials.json"

ENTRYPOINT ["/app/cameradar"]

Here is a Dockerfile that allow you to get a successful build.


# Build stage
FROM golang:alpine AS build-env

COPY . /go/src/github.com/Ullaakut/cameradar
WORKDIR /go/src/github.com/Ullaakut/cameradar/cmd/cameradar

RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> `/etc/apk/repositories`

RUN apk update && \
    apk add nmap nmap-nselibs nmap-scripts \
    gcc \
    libc-dev \
    git \
    pkgconfig \
    curl==7.79.1-r3 \
    curl-dev==7.79.1-r3
ENV GO111MODULE=on
RUN go version
RUN go build -o cameradar

# Final stage
FROM alpine

# Necessary to install curl v7.64.0-r3.
# Fix for https://github.com/Ullaakut/cameradar/issues/247
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.9/main' >> /etc/apk/repositories

RUN apk --update add --no-cache nmap \
    nmap-nselibs \
    nmap-scripts \
    curl-dev==7.64.0-r5 \
    curl==7.64.0-r5

WORKDIR /app/cameradar
COPY --from=build-env /go/src/github.com/Ullaakut/cameradar/dictionaries/ /app/dictionaries/
COPY --from=build-env /go/src/github.com/Ullaakut/cameradar/cmd/cameradar/ /app/cameradar/

ENV CAMERADAR_CUSTOM_ROUTES="/app/dictionaries/routes"
ENV CAMERADAR_CUSTOM_CREDENTIALS="/app/dictionaries/credentials.json"

ENTRYPOINT ["/app/cameradar/cameradar"]

Don’t know how anyone would discover any similarities in potential issues with the issue labeled as ambiguously as it is. It might be a good idea to change this… just saying.

I don’t really have the time to troubleshoot a resolution to this issue at the moment, but the resolution to downgrade to golang:1.16-alpine3.13 does not sit well.

As for simply replacing Ullaakut with andelf, it does not work. The go version designation includes a 12 character hash at the end, and how to discover the appropriate hash I do not know.

I will have to look at this when I have more time.

My version of go-curl is even older than that, the main branch of andelf indeed fixes the thing I tried to fix in my fork, on top of also making further changes, so either way we should replace the dependency. However indeed, it seems like there is a problem with the curl version.

Likely what would fix it then is to change the version of libcurl that is installed in the first step of the Dockerfile:

# Build stage
FROM golang:alpine AS build-env

COPY . /go/src/github.com/Ullaakut/cameradar
WORKDIR /go/src/github.com/Ullaakut/cameradar/cmd/cameradar

RUN apk update && \
    apk upgrade && \
    apk add nmap nmap-nselibs nmap-scripts \
    curl curl-dev \ # <------------------------------------------------------ Here.
    gcc \
    libc-dev \
    git \
    pkgconfig
ENV GO111MODULE=on
RUN go version
RUN go build -o cameradar

In the last stage, we specify the version of curl we want to get a very specific one, but it looks like the build stage now fails due to the curl version that matches the package manager in the golang:alpine image.

I can’t look into it at the moment unfortunately.

I also encountered such a problem… I feel that you are wrong, the last update of the library andelf/go-curl is 3 years ago. It means that no changes have been made in the library to correct andelf/go-curl and the problem is somewhere else

However, we will try Thank @Ullaakut

If you want to fix it, all you need to do is replace the dependency from https://github.com/Ullaakut/go-curl to https://github.com/andelf/go-curl. That should be enough to allow you to build the docker image.

Have a good day!

Thanks for opening this issue, this shows that Ullaakut/go-curl is outdated, and after looking into it it seems that the fix I did on go-curl in my fork has been done on the original repo as well, so we can use go-curl instead of my version of it, and that should fix it.

If someone wants to pick this up, feel free to update the dependency, otherwise I’ll do it when I have some time +1

Thanks for opening this issue, this shows that Ullaakut/go-curl is outdated, and after looking into it it seems that the fix I did on go-curl in my fork has been done on the original repo as well, so we can use go-curl instead of my version of it, and that should fix it.

If someone wants to pick this up, feel free to update the dependency, otherwise I’ll do it when I have some time +1

### Please help me to fix this issue @Ullaakut 🙏️🙏️🙏️