dockeraws-lambdaclamav

Docker clamav AWS lambda layer build on mac M1


Attempting to run the docker file from here

https://dev.to/sutt0n/using-a-lambda-container-to-scan-files-with-clamav-via-serverless-2a5g

I get an error

=> ERROR [10/52] RUN yumdownloader -x *i686 --archlist=x86_64 clamav

#13 4.564 64 packages excluded due to repository priority protections
#13 4.623 No Match for argument clamav
#13 4.623 Nothing to download

I am guessing that I need the i686 binary to run on AWS. How to get this to work?

Epel is installed

 => CACHED [ 9/54] RUN amazon-linux-extras install epel -y                                                                                                                                                                                                                                                                                                         0.0s
 => [10/54] RUN yum install -y epel-release                                                                                                                                                                                                                                                                                                                        3.4s
 => [11/54] RUN yum install -y cpio yum-utils tar.x86_64 gzip zip       

I started the docker container and login

docker exec -it 31a81f061b7e bash

Editing cat /etc/yum/pluginconf.d/priorities.conf does nothing.

# yum repolist
Loaded plugins: ovl, priorities
213 packages excluded due to repository priority protections

repo id                 repo name                         status
amzn2-core/2/aarch64    Amazon Linux 2 core repository    19985
amzn2extra-epel/2/aarch64  Amazon Extras repo for epel    1 
epel/aarch64             Extra Packages for Enterprise Linux 7 - aarch64       12775+213

repolist: 32761

Shows ARM architecture.

 # yum search clamav
 Loaded plugins: ovl
 === N/S matched: clamav ========
clamav-filesystem.noarch : Filesystem structure for clamav
clamav-unofficial-sigs.noarch : Scripts to download unofficial clamav signatures
clamav.aarch64 : End-user tools for the Clam Antivirus scanner
clamav-data.noarch : Virus signature data for the Clam Antivirus scanner.
clamav-devel.aarch64 : Header files and libraries for the Clam Antivirus scanner
 clamav-lib.aarch64 : Dynamic libraries for the Clam Antivirus scanner
clamav-milter.aarch64 : Milter module for the Clam Antivirus scanner
clamav-update.aarch64 : Auto-updater for the Clam Antivirus scanner data-files

Probably clamav.aarch64.

Take a guess, edit the Dockerfile. Sadly no.

 ERROR [11/53] RUN yumdownloader -x *i686 --archlist=x86_64 clamav.x86_64  

Solution

  • Hunch regarding platform seems to have been correct. Take Sutton's Dockerfile and specify a platform. Randomly chose 'amd64' as opposed to x86-64 which seems more logical as per a derivative blog post

    FROM --platform=linux/amd64 amazonlinux:2
    
    WORKDIR /home/build
    
    RUN set -e