64 lines
2.4 KiB
Docker
64 lines
2.4 KiB
Docker
|
|
# Firegex Dockerfile UUID signature
|
|
# cf1795af-3284-4183-a888-81ad3590ad84
|
|
# Needed for run.py to detect the Dockerfile
|
|
|
|
|
|
FROM --platform=$BUILDPLATFORM oven/bun AS frontend
|
|
WORKDIR /app
|
|
ADD ./frontend/package.json .
|
|
ADD ./frontend/bun.lock .
|
|
RUN bun i
|
|
COPY ./frontend/ .
|
|
RUN bun run build
|
|
|
|
# Base Ubuntu container
|
|
FROM --platform=$TARGETARCH ubuntu:24.04 AS base
|
|
RUN apt-get update && apt-get install -y python3 libnetfilter-queue1 \
|
|
libnfnetlink0 libmnl0 libcap-ng-utils libcap2-bin nftables \
|
|
libhyperscan5 python3-nftables libpcap0.8 && \
|
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN mkdir -p /execute/modules
|
|
WORKDIR /execute
|
|
|
|
FROM --platform=$TARGETARCH base AS compiler
|
|
|
|
RUN apt-get update && apt-get install -y python3-dev build-essential g++ \
|
|
libnetfilter-queue-dev libnfnetlink-dev libmnl-dev \
|
|
libhyperscan-dev libpcap-dev libboost-dev pkg-config wget cmake && \
|
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Build libtins from source as it's not available in Ubuntu 24.04
|
|
RUN wget https://github.com/mfontanini/libtins/archive/v4.5.tar.gz && \
|
|
tar -xzf v4.5.tar.gz && cd libtins-4.5 && \
|
|
mkdir build && cd build && \
|
|
cmake ../ -DLIBTINS_ENABLE_CXX11=1 && \
|
|
make && make install && ldconfig && \
|
|
cd ../.. && rm -rf libtins-4.5 v4.5.tar.gz
|
|
|
|
COPY ./backend/binsrc /execute/binsrc
|
|
RUN g++ binsrc/nfregex.cpp -o cppregex -std=c++23 -O3 -lnetfilter_queue -pthread -lnfnetlink $(pkg-config --cflags --libs libtins libhs libmnl)
|
|
RUN g++ binsrc/nfproxy.cpp -o cpproxy -std=c++23 -O3 -lnetfilter_queue -lpython3.12 -pthread -lnfnetlink $(pkg-config --cflags --libs libtins libmnl python3)
|
|
|
|
#Building main conteiner
|
|
FROM --platform=$TARGETARCH base AS final
|
|
|
|
COPY ./backend/requirements.txt /execute/requirements.txt
|
|
COPY ./fgex-lib /execute/fgex-lib
|
|
|
|
RUN apt-get update && apt-get install -y g++ python3-dev python3-pip git && \
|
|
pip3 install --no-cache-dir --break-system-packages ./fgex-lib && \
|
|
pip3 install --no-cache-dir --break-system-packages -r /execute/requirements.txt && \
|
|
apt-get remove -y g++ python3-dev git && \
|
|
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY ./backend/ /execute/
|
|
COPY --from=compiler /execute/cppregex /execute/cpproxy /execute/modules/
|
|
COPY --from=compiler /usr/local/lib/libtins* /usr/local/lib/
|
|
COPY --from=frontend /app/dist/ ./frontend/
|
|
|
|
RUN ldconfig
|
|
|
|
CMD ["/bin/sh", "/execute/docker-entrypoint.sh"]
|