Skip to content

Commit

Permalink
consolidate some dockerfile layers
Browse files Browse the repository at this point in the history
  • Loading branch information
chtakahashi committed Jul 26, 2022
1 parent e04d8ae commit e86a0dc
Showing 1 changed file with 31 additions and 49 deletions.
80 changes: 31 additions & 49 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,63 +11,45 @@ COPY ./*.py /opt/app/
COPY requirements.txt /opt/app/requirements.txt

# Install packages
RUN yum update -y
RUN amazon-linux-extras install epel -y
RUN yum install -y cpio yum-utils tar.x86_64 gzip zip python3-pip

# This had --no-cache-dir, tracing through multiple tickets led to a problem in wheel
RUN pip3 install -r requirements.txt
RUN rm -rf /root/.cache/pip
RUN yum update -y && \
amazon-linux-extras install epel -y && \
yum install -y cpio yum-utils tar.x86_64 gzip zip python3-pip shadow-utils.x86_64 && \
pip3 install -r requirements.txt && \
rm -rf /root/.cache/pip

# Download libraries we need to run in lambda
WORKDIR /tmp
RUN yumdownloader -x \*i686 --archlist=x86_64 clamav
RUN rpm2cpio clamav-0*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 clamav-lib
RUN rpm2cpio clamav-lib*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 clamav-update
RUN rpm2cpio clamav-update*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 json-c
RUN rpm2cpio json-c*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 pcre2
RUN rpm2cpio pcre*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 libtool-ltdl
RUN rpm2cpio libtool-ltdl*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 libxml2
RUN rpm2cpio libxml2*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 bzip2-libs
RUN rpm2cpio bzip2-libs*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 xz-libs
RUN rpm2cpio xz-libs*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 libprelude
RUN rpm2cpio libprelude*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 gnutls
RUN rpm2cpio gnutls*.rpm | cpio -vimd

RUN yumdownloader -x \*i686 --archlist=x86_64 nettle
RUN rpm2cpio nettle*.rpm | cpio -vimd
RUN yumdownloader -x \*i686 --archlist=x86_64 \
clamav clamav-lib clamav-update json-c \
pcre2 libtool-ltdl libxml2 bzip2-libs \
xz-libs libprelude gnutls nettle

RUN rpm2cpio clamav-0*.rpm | cpio -vimd && \
rpm2cpio clamav-lib*.rpm | cpio -vimd && \
rpm2cpio clamav-update*.rpm | cpio -vimd && \
rpm2cpio json-c*.rpm | cpio -vimd && \
rpm2cpio pcre*.rpm | cpio -vimd && \
rpm2cpio libtool-ltdl*.rpm | cpio -vimd && \
rpm2cpio libxml2*.rpm | cpio -vimd && \
rpm2cpio bzip2-libs*.rpm | cpio -vimd && \
rpm2cpio xz-libs*.rpm | cpio -vimd && \
rpm2cpio libprelude*.rpm | cpio -vimd && \
rpm2cpio gnutls*.rpm | cpio -vimd && \
rpm2cpio nettle*.rpm | cpio -vimd


# Copy over the binaries and libraries
RUN cp /tmp/usr/bin/clamscan /tmp/usr/bin/freshclam /tmp/usr/lib64/* /usr/lib64/libpcre.so.1 /opt/app/bin/
RUN cp /tmp/usr/bin/clamscan \
/tmp/usr/bin/freshclam \
/tmp/usr/lib64/* \
/usr/lib64/libpcre.so.1 \
/opt/app/bin/

# 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
RUN echo "ScriptedUpdates no" >> /opt/app/bin/freshclam.conf
RUN echo "DatabaseDirectory /var/lib/clamav" >> /opt/app/bin/freshclam.conf

RUN yum install shadow-utils.x86_64 -y
RUN echo "DatabaseMirror database.clamav.net" > /opt/app/bin/freshclam.conf && \
echo "CompressLocalDatabase yes" >> /opt/app/bin/freshclam.conf && \
echo "ScriptedUpdates no" >> /opt/app/bin/freshclam.conf && \
echo "DatabaseDirectory /var/lib/clamav" >> /opt/app/bin/freshclam.conf

RUN groupadd clamav
RUN useradd -g clamav -s /bin/false -c "Clam Antivirus" clamav
Expand Down

0 comments on commit e86a0dc

Please sign in to comment.