Cisco-Talos / clamav-docker

Dockerfiles for the ClamAV project
35 stars 20 forks source link

Docker build fails with "CMake Error" #20

Open Zappelphilipp opened 1 year ago

Zappelphilipp commented 1 year ago

tried to build the 1.1.0 debian as well as alpine image and both fail:

15.24   Ignoring extra path from command line:
15.24 
15.24    ".."
15.24 
15.24 
15.24 CMake Error: The source directory "/src" does not appear to contain CMakeLists.txt.
15.24 Specify --help for usage, or press the help button on the CMake GUI.

is the file really missing or what is going on here?

i am using gitlab runner for building.

gschafra commented 1 year ago

Same here when trying (multiarch) build 1.1.0 alpine on command line (Docker Desktop v4.20.1): image

#0 78.31 CMake Error: The source directory "/src" does not appear to contain CMakeLists.txt.
vienleidl commented 1 year ago

Me, too. I've tested on 0.105, 1.0, 1.1 & unstable with the same issue:

45.42 CMake Error: The source directory "/src" does not appear to contain CMakeLists.txt.
45.42 Specify --help for usage, or press the help button on the CMake GUI.
micahsnyder commented 1 year ago

We haven't really finished stabilizing the Debian dockerfiles. I guess I wouldn't be surprised if something is broken.

vienleidl commented 1 year ago

We haven't really finished stabilizing the Debian dockerfiles. I guess I wouldn't be surprised if something is broken.

Sorry that I meant the alpine image, not the Debian one.

micahsnyder commented 1 year ago

Hey all, I think the issue you're facing is that since we moved the Dockerfile stuff from the main clamav repo over to here -- we forgot to update our build instructions to tell you that you need to copy the Dockerfile and scripts directory into the clamav source directory before trying to compile.

I will push up and update soon that adds this detail to our build instructions. I think we'll also need to rework the README as well because the build instructions for the bytecode compiler will also be different, so we may end up with several layers of README files.

vienleidl commented 1 year ago

Hey all, I think the issue you're facing is that since we moved the Dockerfile stuff from the main clamav repo over to here -- we forgot to update our build instructions to tell you that you need to copy the Dockerfile and scripts directory into the clamav source directory before trying to compile.

I will push up and update soon that adds this detail to our build instructions. I think we'll also need to rework the README as well because the build instructions for the bytecode compiler will also be different, so we may end up with several layers of README files.

Hi @micahsnyder , thanks a lot for your information. Sorry for making the confusion. I don't use docker build, just pull & run the clamav/clamav images and found that issue.

micahsnyder commented 1 year ago

@vienleidl I'm quite confused. The error described above is one you would get from trying to build the image.

vienleidl commented 1 year ago

Me, too. I've tested on 0.105, 1.0, 1.1 & unstable with the same issue:

45.42 CMake Error: The source directory "/src" does not appear to contain CMakeLists.txt.
45.42 Specify --help for usage, or press the help button on the CMake GUI.

Hi @micahsnyder, never mind! 2 weeks ago, I pulled and ran these images of clamav/clamav: latest, 0.105, 1.0, 1.1 & unstable. I didn't build. The container was crashing and failed to start with the above errors. But now I've just tested again and they are gone. Even though, the container now is loaded successfully, but I still see some errors keep appearing:

2023-08-16T04:15:32.906651973Z Starting Freshclamd
2023-08-16T04:15:32.906691818Z Starting ClamAV
2023-08-16T04:15:32.948049634Z 
Socket for clamd not found yet, retrying (0/1800) ...ClamAV update process started at Wed Aug 16 04:15:32 2023
2023-08-16T04:15:32.951246669Z daily database available for update (local version: 26999, remote version: 27001)
Socket for clamd not found yet, retrying (1/1800) ...
Socket for clamd not found yet, retrying (2/1800) ...
Socket for clamd not found yet, retrying (3/1800) ...
Socket for clamd not found yet, retrying (4/1800) ...
Socket for clamd not found yet, retrying (5/1800) ...
Socket for clamd not found yet, retrying (6/1800) ...
Socket for clamd not found yet, retrying (7/1800) ...
Socket for clamd not found yet, retrying (8/1800) ...WARNING:  ******* RESULT 200, SIZE: 2507 ******* 
Socket for clamd not found yet, retrying (9/1800) ...WARNING:  ******* RESULT 200, SIZE: 1919 ******* 
Socket for clamd not found yet, retrying (10/1800) ...
Socket for clamd not found yet, retrying (11/1800) ...
Socket for clamd not found yet, retrying (12/1800) ...Testing database: '/var/lib/clamav/tmp.63bf96170a/clamav-a08523a6b7b97fec2273761333390f48.tmp-daily.cld' ...
2023-08-16T04:16:03.755336838Z 
Socket for clamd not found yet, retrying (13/1800) ...
Socket for clamd not found yet, retrying (14/1800) ...
Socket for clamd not found yet, retrying (15/1800) ...
Socket for clamd not found yet, retrying (16/1800) ...
Socket for clamd not found yet, retrying (17/1800) ...
Socket for clamd not found yet, retrying (18/1800) ...
Socket for clamd not found yet, retrying (19/1800) ...
Socket for clamd not found yet, retrying (20/1800) ...
...
Socket for clamd not found yet, retrying (30/1800) ...ERROR: Database load killed by signal 9
2023-08-16T04:16:03.755353258Z ERROR: Database test FAILED.
2023-08-16T04:16:03.758721834Z ERROR: Unexpected error when attempting to update daily: Test failed
2023-08-16T04:16:03.758730621Z ERROR: Database update process failed: Test failed
2023-08-16T04:16:03.758806117Z ERROR: Update failed.
...
Socket for clamd not found yet, retrying (239/1800) ...
micahsnyder commented 1 year ago

@vienleidl you probably have not allocated enough memory for the images. You should provide them with at least 4GB of RAM with the default configuration, or else 2GB or maybe 3GB of RAM if you set the ConcurrentDatabaseReload no in clamd.conf.

If you plan to change the configuration to support scanning much larger files, then I would recommend allocating 6GB for each container.

vienleidl commented 1 year ago

@vienleidl you probably have not allocated enough memory for the images. You should provide them with at least 4GB of RAM with the default configuration, or else 2GB or maybe 3GB of RAM if you set the ConcurrentDatabaseReload no in clamd.conf.

If you plan to change the configuration to support scanning much larger files, then I would recommend allocating 6GB for each container.

Great! Thanks a lot for your suggestion! I've just tested on Azure Container Apps with 2 GB of memory. It works well.

2023-08-17T08:59:51.052325638Z socket found, clamd started.
2023-08-17T09:09:54.146169367Z Thu Aug 17 09:09:54 2023 -> SelfCheck: Database status OK.
gabrielrosset commented 8 months ago

Hey all, I think the issue you're facing is that since we moved the Dockerfile stuff from the main clamav repo over to here -- we forgot to update our build instructions to tell you that you need to copy the Dockerfile and scripts directory into the clamav source directory before trying to compile.

I will push up and update soon that adds this detail to our build instructions. I think we'll also need to rework the README as well because the build instructions for the bytecode compiler will also be different, so we may end up with several layers of README files.

This is obviously not enough, Dockerfile cmake command needs a CMakeLists.txt which use its variables passed in arguments into https://github.com/Cisco-Talos/clamav-docker/blob/main/clamav/1.0/alpine/Dockerfile#L46 . It seems your CI take this "CMakeLists.txt" from elsewhere, so by now images in this repo cannot be rebuilt without your CI.

vienleidl commented 8 months ago

Hey all, I think the issue you're facing is that since we moved the Dockerfile stuff from the main clamav repo over to here -- we forgot to update our build instructions to tell you that you need to copy the Dockerfile and scripts directory into the clamav source directory before trying to compile.

I will push up and update soon that adds this detail to our build instructions. I think we'll also need to rework the README as well because the build instructions for the bytecode compiler will also be different, so we may end up with several layers of README files.

I have the same issue on Alpine images. Do you know when it will be fixed? Thank you very much!

micahsnyder commented 8 months ago

Hey all, I think the issue you're facing is that since we moved the Dockerfile stuff from the main clamav repo over to here -- we forgot to update our build instructions to tell you that you need to copy the Dockerfile and scripts directory into the clamav source directory before trying to compile. I will push up and update soon that adds this detail to our build instructions. I think we'll also need to rework the README as well because the build instructions for the bytecode compiler will also be different, so we may end up with several layers of README files.

I have the same issue on Alpine images. Do you know when it will be fixed? Thank you very much!

@vienleidl you don't need to wait for a fix. If you want to build a clamav image, just

  1. clone the https://github.com/Cisco-Talos/clamav.git repository.
  2. git checkout the branch or tag you desire to build (e.g. git checkout clamav-1.2.1)
  3. copy the Dockerfile and scripts/ for the Alpine or Debian image that matches the version from this repo. E.g. in a terminal from your clamav code directory, run something like this (may vary depending on your paths):
    cp -r ~/clamav-docker/clamav/1.2/alpine/scripts ~/clamav-docker/clamav/1.2/alpine/Dockerfile .
  4. run your docker build: docker build --tag yourtag .
vienidl commented 6 months ago

Hey all, I think the issue you're facing is that since we moved the Dockerfile stuff from the main clamav repo over to here -- we forgot to update our build instructions to tell you that you need to copy the Dockerfile and scripts directory into the clamav source directory before trying to compile. I will push up and update soon that adds this detail to our build instructions. I think we'll also need to rework the README as well because the build instructions for the bytecode compiler will also be different, so we may end up with several layers of README files.

I have the same issue on Alpine images. Do you know when it will be fixed? Thank you very much!

@vienleidl you don't need to wait for a fix. If you want to build a clamav image, just

  1. clone the https://github.com/Cisco-Talos/clamav.git repository.
  2. git checkout the branch or tag you desire to build (e.g. git checkout clamav-1.2.1)
  3. copy the Dockerfile and scripts/ for the Alpine or Debian image that matches the version from this repo. E.g. in a terminal from your clamav code directory, run something like this (may vary depending on your paths):
    cp -r ~/clamav-docker/clamav/1.2/alpine/scripts ~/clamav-docker/clamav/1.2/alpine/Dockerfile .
  4. run your docker build: docker build --tag yourtag .

I tried but another one occured ERROR: failed to solve: process "/bin/sh -c apk update && apk upgrade && apk add --no-cache bsd-compat-headers cmake file g++ libtool linux-headers make musl-fts-dev bzip2-dev check-dev curl-dev json-c-dev libmilter-dev libxml2-dev ncurses-dev ncurses-dev openssl-dev pcre2-dev zlib-dev python3 py3-pytest cargo rust && mkdir -p \"./build\" && cd \"./build\" && cmake .. -D CMAKE_BUILD_TYPE=\"Release\" -D CMAKE_INSTALL_PREFIX=\"/usr\" -D CMAKE_INSTALL_LIBDIR=\"/usr/lib\" -D APP_CONFIG_DIRECTORY=\"/etc/clamav\" -D DATABASE_DIRECTORY=\"/var/lib/clamav\" -D ENABLE_CLAMONACC=OFF -D ENABLE_EXAMPLES=OFF -D ENABLE_MILTER=ON -D ENABLE_MAN_PAGES=OFF -D ENABLE_STATIC_LIB=OFF -D ENABLE_JSON_SHARED=ON && make DESTDIR=\"/clamav\" -j$(($(nproc) - 1)) install && rm -r \"/clamav/usr/lib/pkgconfig/\" && sed -e \"s|^\\(Example\\)|\\# \\1|\" -e \"s|.*\\(PidFile\\) .*|\\1 /tmp/clamd.pid|\" -e \"s|.*\\(LocalSocket\\) .*|\\1 /tmp/clamd.sock|\" -e \"s|.*\\(TCPSocket\\) .*|\\1 3310|\" -e \"s|.*\\(TCPAddr\\) .*|#\\1 0.0.0.0|\" -e \"s|.*\\(User\\) .*|\\1 clamav|\" -e \"s|^\\#\\(LogFile\\) .*|\\1 /var/log/clamav/clamd.log|\" -e \"s|^\\#\\(LogTime\\).*|\\1 yes|\" \"/clamav/etc/clamav/clamd.conf.sample\" > \"/clamav/etc/clamav/clamd.conf\" && sed -e \"s|^\\(Example\\)|\\# \\1|\" -e \"s|.*\\(PidFile\\) .*|\\1 /tmp/freshclam.pid|\" -e \"s|.*\\(DatabaseOwner\\) .*|\\1 clamav|\" -e \"s|^\\#\\(UpdateLogFile\\) .*|\\1 /var/log/clamav/freshclam.log|\" -e \"s|^\\#\\(NotifyClamd\\).*|\\1 /etc/clamav/clamd.conf|\" -e \"s|^\\#\\(ScriptedUpdates\\).*|\\1 yes|\" \"/clamav/etc/clamav/freshclam.conf.sample\" > \"/clamav/etc/clamav/freshclam.conf\" && sed -e \"s|^\\(Example\\)|\\# \\1|\" -e \"s|.*\\(PidFile\\) .*|\\1 /tmp/clamav-milter.pid|\" -e \"s|.*\\(MilterSocket\\) .*|\\1 inet:7357|\" -e \"s|.*\\(User\\) .*|\\1 clamav|\" -e \"s|^\\#\\(LogFile\\) .*|\\1 /var/log/clamav/milter.log|\" -e \"s|^\\#\\(LogTime\\).*|\\1 yes|\" -e \"s|.*\\(\\ClamdSocket\\) .*|\\1 unix:/tmp/clamd.sock|\" \"/clamav/etc/clamav/clamav-milter.conf.sample\" > \"/clamav/etc/clamav/clamav-milter.conf\" || exit 1 && ctest -V" did not complete successfully: exit code: 8

xposix commented 6 months ago

I'm too having the same issue, I'm building from 'main' debian version 1.3. There are no other branches / tags in this repo.

(...)
211.9 To configure your current shell, run:
211.9 source "/src/build/env"
212.0 info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
212.8 info: checking for self-update
212.9
212.9   stable-x86_64-unknown-linux-gnu unchanged - rustc 1.76.0 (07dca489a 2024-02-04)
212.9
212.9 info: cleaning up downloads & tmp directories
213.0 CMake Error: The source directory "/src" does not appear to contain CMakeLists.txt.
213.0 Specify --help for usage, or press the help button on the CMake GUI.
------
Dockerfile:16
--------------------
  15 |
  16 | >>> RUN apt update && apt install -y \
  17 | >>>         cmake \
  18 | >>>         bison \
  19 | >>>         flex \
  20 | >>>         gcc \
  21 | >>>         git \
  22 | >>>         make \
  23 | >>>         man-db \
  24 | >>>         net-tools \
  25 | >>>         pkg-config \
  26 | >>>         python3 \
  27 | >>>         python3-pip \
  28 | >>>         python3-pytest \
  29 | >>>         check \
  30 | >>>         libbz2-dev \
  31 | >>>         libcurl4-openssl-dev \
  32 | >>>         libjson-c-dev \
  33 | >>>         libmilter-dev \
  34 | >>>         libncurses-dev \
  35 | >>>         libpcre2-dev \
  36 | >>>         libssl-dev \
  37 | >>>         libxml2-dev \
  38 | >>>         zlib1g-dev \
  39 | >>>         curl \
  40 | >>>     && \
  41 | >>>     rm -rf /var/cache/apt/archives \
  42 | >>>     && \
  43 | >>>     # Using rustup to install Rust rather than rust:1.62.1-bullseye, because there is no rust:1.62.1-bullseye image for ppc64le at this time.
  44 | >>>     curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
  45 | >>>     && \
  46 | >>>     . $CARGO_HOME/env \
  47 | >>>     && \
  48 | >>>     rustup update \
  49 | >>>     && \
  50 | >>>     mkdir -p "./build" && cd "./build" \
  51 | >>>     && \
  52 | >>>     cmake .. \
  53 | >>>           -DCARGO_HOME=$CARGO_HOME \
  54 | >>>           -DCMAKE_BUILD_TYPE="Release" \
  55 | >>>           -DCMAKE_INSTALL_PREFIX="/usr" \
  56 | >>>           -DCMAKE_INSTALL_LIBDIR="/usr/lib" \
  57 | >>>           -DAPP_CONFIG_DIRECTORY="/etc/clamav" \
  58 | >>>           -DDATABASE_DIRECTORY="/var/lib/clamav" \
  59 | >>>           -DENABLE_CLAMONACC=OFF \
  60 | >>>           -DENABLE_EXAMPLES=OFF \
  61 | >>>           -DENABLE_JSON_SHARED=ON \
  62 | >>>           -DENABLE_MAN_PAGES=OFF \
  63 | >>>           -DENABLE_MILTER=ON \
  64 | >>>           -DENABLE_STATIC_LIB=OFF \
  65 | >>>     && \
  66 | >>>     make DESTDIR="/clamav" -j$(($(nproc) - 1)) install \
  67 | >>>     && \
  68 | >>>     rm -r \
  69 | >>>        "/clamav/usr/include" \
  70 | >>>        "/clamav/usr/lib/pkgconfig/" \
  71 | >>>     && \
  72 | >>>     sed -e "s|^\(Example\)|\# \1|" \
  73 | >>>         -e "s|.*\(PidFile\) .*|\1 /tmp/clamd.pid|" \
  74 | >>>         -e "s|.*\(LocalSocket\) .*|\1 /tmp/clamd.sock|" \
  75 | >>>         -e "s|.*\(TCPSocket\) .*|\1 3310|" \
  76 | >>>         -e "s|.*\(TCPAddr\) .*|#\1 0.0.0.0|" \
  77 | >>>         -e "s|.*\(User\) .*|\1 clamav|" \
  78 | >>>         -e "s|^\#\(LogFile\) .*|\1 /var/log/clamav/clamd.log|" \
  79 | >>>         -e "s|^\#\(LogTime\).*|\1 yes|" \
  80 | >>>         "/clamav/etc/clamav/clamd.conf.sample" > "/clamav/etc/clamav/clamd.conf" && \
  81 | >>>     sed -e "s|^\(Example\)|\# \1|" \
  82 | >>>         -e "s|.*\(PidFile\) .*|\1 /tmp/freshclam.pid|" \
  83 | >>>         -e "s|.*\(DatabaseOwner\) .*|\1 clamav|" \
  84 | >>>         -e "s|^\#\(UpdateLogFile\) .*|\1 /var/log/clamav/freshclam.log|" \
  85 | >>>         -e "s|^\#\(NotifyClamd\).*|\1 /etc/clamav/clamd.conf|" \
  86 | >>>         -e "s|^\#\(ScriptedUpdates\).*|\1 yes|" \
  87 | >>>         "/clamav/etc/clamav/freshclam.conf.sample" > "/clamav/etc/clamav/freshclam.conf" && \
  88 | >>>     sed -e "s|^\(Example\)|\# \1|" \
  89 | >>>         -e "s|.*\(PidFile\) .*|\1 /tmp/clamav-milter.pid|" \
  90 | >>>         -e "s|.*\(MilterSocket\) .*|\1 inet:7357|" \
  91 | >>>         -e "s|.*\(User\) .*|\1 clamav|" \
  92 | >>>         -e "s|^\#\(LogFile\) .*|\1 /var/log/clamav/milter.log|" \
  93 | >>>         -e "s|^\#\(LogTime\).*|\1 yes|" \
  94 | >>>         -e "s|.*\(\ClamdSocket\) .*|\1 unix:/tmp/clamd.sock|" \
  95 | >>>         "/clamav/etc/clamav/clamav-milter.conf.sample" > "/clamav/etc/clamav/clamav-milter.conf" || \
  96 | >>>     exit 1 \
  97 | >>>     && \
  98 | >>>     ctest -V
  99 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apt update && apt install -y         cmake         bison         flex         gcc         git         make         man-db         net-tools         pkg-config         python3         python3-pip         python3-pytest         check         libbz2-dev         libcurl4-openssl-dev         libjson-c-dev         libmilter-dev
libncurses-dev         libpcre2-dev         libssl-dev         libxml2-dev         zlib1g-dev         curl     &&     rm -rf /var/cache/apt/archives     &&     curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y     &&     . $CARGO_HOME/env     &&     rustup update     &&     mkdir -p \"./build\" && cd \"./build\"     &&     cmake ..           -DCARGO_HOME=$CARGO_HOME           -DCMAKE_BUILD_TYPE=\"Release\"           -DCMAKE_INSTALL_PREFIX=\"/usr\"           -DCMAKE_INSTALL_LIBDIR=\"/usr/lib\"           -DAPP_CONFIG_DIRECTORY=\"/etc/clamav\"           -DDATABASE_DIRECTORY=\"/var/lib/clamav\"           -DENABLE_CLAMONACC=OFF           -DENABLE_EXAMPLES=OFF           -DENABLE_JSON_SHARED=ON           -DENABLE_MAN_PAGES=OFF           -DENABLE_MILTER=ON           -DENABLE_STATIC_LIB=OFF     &&     make DESTDIR=\"/clamav\" -j$(($(nproc) - 1)) install     &&     rm -r        \"/clamav/usr/include\"        \"/clamav/usr/lib/pkgconfig/\"     &&     sed -e \"s|^\\(Example\\)|\\# \\1|\"         -e \"s|.*\\(PidFile\\) .*|\\1 /tmp/clamd.pid|\"         -e \"s|.*\\(LocalSocket\\) .*|\\1 /tmp/clamd.sock|\"         -e \"s|.*\\(TCPSocket\\) .*|\\1 3310|\"         -e \"s|.*\\(TCPAddr\\) .*|#\\1 0.0.0.0|\"         -e \"s|.*\\(User\\) .*|\\1 clamav|\"         -e \"s|^\\#\\(LogFile\\) .*|\\1 /var/log/clamav/clamd.log|\"         -e \"s|^\\#\\(LogTime\\).*|\\1 yes|\"         \"/clamav/etc/clamav/clamd.conf.sample\" > \"/clamav/etc/clamav/clamd.conf\" &&     sed -e \"s|^\\(Example\\)|\\# \\1|\"         -e \"s|.*\\(PidFile\\) .*|\\1 /tmp/freshclam.pid|\"         -e \"s|.*\\(DatabaseOwner\\) .*|\\1 clamav|\"         -e \"s|^\\#\\(UpdateLogFile\\) .*|\\1 /var/log/clamav/freshclam.log|\"         -e \"s|^\\#\\(NotifyClamd\\).*|\\1 /etc/clamav/clamd.conf|\"         -e \"s|^\\#\\(ScriptedUpdates\\).*|\\1 yes|\"         \"/clamav/etc/clamav/freshclam.conf.sample\" > \"/clamav/etc/clamav/freshclam.conf\" &&     sed -e \"s|^\\(Example\\)|\\# \\1|\"         -e \"s|.*\\(PidFile\\) .*|\\1 /tmp/clamav-milter.pid|\"         -e \"s|.*\\(MilterSocket\\) .*|\\1 inet:7357|\"         -e \"s|.*\\(User\\) .*|\\1 clamav|\"         -e \"s|^\\#\\(LogFile\\) .*|\\1 /var/log/clamav/milter.log|\"         -e \"s|^\\#\\(LogTime\\).*|\\1 yes|\"         -e \"s|.*\\(\\ClamdSocket\\) .*|\\1 unix:/tmp/clamd.sock|\"         \"/clamav/etc/clamav/clamav-milter.conf.sample\" > \"/clamav/etc/clamav/clamav-milter.conf\" ||     exit 1     &&     ctest -V" did not complete successfully: exit code: 1
xposix commented 6 months ago

I tried Debian version 1.2 and had the same issue clamav/1.2/debian/Dockerfile

micahsnyder commented 6 months ago

213.0 CMake Error: The source directory "/src" does not appear to contain CMakeLists.txt.

This error message implies you did not place Dockerfile (and scripts directory) inside the clamav source code directory before building.

@xposix Did you follow these directions? https://github.com/Cisco-Talos/clamav-docker/issues/20#issuecomment-1894336122

xposix commented 6 months ago

Sorry yes I just realized that building the image is not straightforward and instructions need to be followed. Sorry and thank you!