Last active
December 20, 2022 09:04
-
-
Save serverwentdown/81eb6e285c5ff2428332ba2910082229 to your computer and use it in GitHub Desktop.
An Earthfile (https://earthly.dev) describing the build of snort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VERSION 0.6 | |
FROM ubuntu:20.04 | |
ARG DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update \ | |
&& apt-get install --yes \ | |
libdumbnet1 libluajit-5.1-2 libpcap0.8 \ | |
zlib1g libhwloc15 liblzma5 libssl1.1 \ | |
libunwind8 \ | |
libmnl0 libjemalloc2 \ | |
&& rm -rf /var/lib/apt/lists/* | |
build: | |
RUN apt-get update \ | |
&& apt-get install --yes \ | |
wget tar gzip \ | |
python \ | |
build-essential autotools-dev libdumbnet-dev libluajit-5.1-dev libpcap-dev \ | |
zlib1g-dev pkg-config libhwloc-dev cmake liblzma-dev openssl libssl-dev cpputest libsqlite3-dev \ | |
libtool uuid-dev git autoconf bison flex libcmocka-dev libnetfilter-queue-dev libunwind-dev \ | |
libmnl-dev ethtool libjemalloc-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN wget -O safeclib.tar.gz https://github.com/rurban/safeclib/releases/download/v3.7.1/safeclib-3.7.1.tar.gz \ | |
&& tar -xzvf safeclib.tar.gz \ | |
&& cd safeclib*/ \ | |
&& ./configure \ | |
&& make \ | |
&& make install \ | |
&& cd .. \ | |
&& rm -rf safeclib* | |
RUN wget -O pcre.tar.gz https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz \ | |
&& tar -xzvf pcre.tar.gz \ | |
&& cd pcre*/ \ | |
&& ./configure \ | |
&& make \ | |
&& make install \ | |
&& cd .. \ | |
&& rm -rf pcre* | |
RUN wget -O gperftools.tar.gz https://github.com/gperftools/gperftools/releases/download/gperftools-2.10/gperftools-2.10.tar.gz \ | |
&& tar -xzvf gperftools.tar.gz \ | |
&& cd gperftools*/ \ | |
&& ./configure \ | |
&& make \ | |
&& make install \ | |
&& cd .. \ | |
&& rm -rf gperftools* | |
RUN wget -O ragel.tar.gz https://www.colm.net/files/ragel/ragel-6.10.tar.gz \ | |
&& tar -xzvf ragel.tar.gz \ | |
&& cd ragel* \ | |
&& ./configure \ | |
&& make \ | |
&& make install \ | |
&& cd .. \ | |
&& rm -rf ragel* | |
RUN wget -O boost.tar.gz https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz \ | |
&& tar -xzvf boost.tar.gz \ | |
&& mv boost*/ boost \ | |
&& rm boost.tar.gz \ | |
&& wget -O hyperscan.tar.gz https://github.com/intel/hyperscan/archive/refs/tags/v5.4.0.tar.gz \ | |
&& tar -xzvf hyperscan.tar.gz \ | |
&& mv hyperscan*/ hyperscan \ | |
&& mkdir hyperscan-build \ | |
&& cd hyperscan-build \ | |
&& cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBOOST_ROOT=../boost ../hyperscan \ | |
&& make \ | |
&& make install \ | |
&& cd .. \ | |
&& rm -rf boost* hyperscan* | |
RUN wget -O flatbuffers.tar.gz https://github.com/google/flatbuffers/archive/refs/tags/v22.12.06.tar.gz \ | |
&& tar -xzvf flatbuffers.tar.gz \ | |
&& mv flatbuffers*/ flatbuffers \ | |
&& mkdir flatbuffers-build \ | |
&& cd flatbuffers-build \ | |
&& cmake ../flatbuffers \ | |
&& make \ | |
&& make install \ | |
&& cd .. \ | |
&& rm -rf flatbuffers* | |
RUN wget -O libdaq.tar.gz https://github.com/snort3/libdaq/archive/refs/tags/v3.0.9.tar.gz \ | |
&& tar -xzvf libdaq.tar.gz \ | |
&& cd libdaq*/ \ | |
&& ./bootstrap \ | |
&& ./configure \ | |
&& make \ | |
&& make install \ | |
&& cd .. \ | |
&& rm -rf libdaq* | |
RUN wget -O snort3.tar.gz https://github.com/snort3/snort3/archive/refs/tags/3.1.47.0.tar.gz \ | |
&& tar -xzvf snort3.tar.gz \ | |
&& cd snort3*/ \ | |
&& ./configure_cmake.sh --prefix=/usr/local --enable-tcmalloc --enable-jemalloc \ | |
&& cd build \ | |
&& make \ | |
&& make install \ | |
&& cd ../.. \ | |
&& rm -rf snort3* | |
RUN ldconfig | |
# Clean up static library files | |
RUN rm -rf \ | |
/usr/local/lib/**.a \ | |
/usr/local/lib/**.la \ | |
/usr/local/lib/cmake | |
SAVE ARTIFACT /etc/ld.so.cache /etc/ld.so.cache | |
SAVE ARTIFACT /usr/local /usr/local | |
minify: | |
COPY +build/etc/ld.so.cache /etc/ld.so.cache | |
COPY +build/usr/local /usr/local | |
docker: | |
FROM +minify | |
ARG tag="latest" | |
ENTRYPOINT ["snort"] | |
SAVE IMAGE snort:$tag | |
test: | |
FROM +minify | |
RUN /usr/local/bin/snort -V | |
RUN snort -c /usr/local/etc/snort/snort.lua | |
dust: | |
FROM +minify | |
RUN apt-get update \ | |
&& apt-get install --yes wget \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN wget -O dust.tar.gz https://github.com/bootandy/dust/releases/download/v0.8.3/dust-v0.8.3-x86_64-unknown-linux-gnu.tar.gz \ | |
&& tar -xzvf dust.tar.gz \ | |
&& mv dust*/dust /usr/local/bin/dust \ | |
&& rm -rf dust* | |
RUN dust -n 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment