forked from bluesentry/bucket-antivirus-function
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
61 lines (45 loc) · 1.92 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
FROM artifactory.aws.wiley.com/docker/amazonlinux:2023 as clamav
ARG clamav_version=1.0.3
RUN yum update -y
RUN yum install -y cpio wget
# Set up working directories
RUN mkdir -p /opt/app/bin/
# Download libraries we need to run in lambda
WORKDIR /tmp
RUN wget https://www.clamav.net/downloads/production/clamav-${clamav_version}.linux.x86_64.rpm -O clamav.rpm -U "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0" --no-verbose
RUN rpm2cpio clamav.rpm | cpio -idmv
# Copy over the binaries and libraries
RUN cp -r /tmp/usr/local/bin/clamdscan \
/tmp/usr/local/sbin/clamd \
/tmp/usr/local/bin/freshclam \
/tmp/usr/local/lib64/* \
/opt/app/bin/
RUN echo "DatabaseDirectory /tmp/clamav_defs" > /opt/app/bin/scan.conf
RUN echo "PidFile /tmp/clamd.pid" >> /opt/app/bin/scan.conf
RUN echo "LogFile /tmp/clamd.log" >> /opt/app/bin/scan.conf
RUN echo "LocalSocket /tmp/clamd.sock" >> /opt/app/bin/scan.conf
RUN echo "FixStaleSocket yes" >> /opt/app/bin/scan.conf
# Fix the freshclam.conf settings
RUN echo "DatabaseMirror database.clamav.net" > /opt/app/bin/freshclam.conf
RUN echo "CompressLocalDatabase yes" >> /opt/app/bin/freshclam.conf
FROM artifactory.aws.wiley.com/docker/amazonlinux:2023
ARG dist=/opt/app
# Install packages
RUN yum update -y
RUN yum install -y python3-pip yum-utils less zip
# Copy in the lambda source
RUN mkdir -p $dist/build
COPY --from=clamav /opt/app/bin /opt/app/bin
COPY ./*.py $dist/
COPY requirements.txt $dist/requirements.txt
# This had --no-cache-dir, tracing through multiple tickets led to a problem in wheel
WORKDIR $dist
RUN pip3 install -r requirements.txt
RUN rm -rf /root/.cache/pip
# Create the zip file
RUN zip -r9 --exclude="*test*" $dist/build/lambda.zip *.py bin
WORKDIR /usr/local/lib/python3.9/site-packages
RUN zip -r9 $dist/build/lambda.zip *
WORKDIR /usr/local/lib64/python3.9/site-packages
RUN zip -r9 $dist/build/lambda.zip *
WORKDIR $dist