ARG LIBSLIRP_COMMIT=v4.3.0
FROM ubuntu:18.04 AS build
RUN apt update && apt install -y automake autotools-dev make gcc libglib2.0-dev libcap-dev libseccomp-dev git ninja-build python3-pip
RUN pip3 install meson
RUN git clone https://gitlab.freedesktop.org/slirp/libslirp.git /libslirp
WORKDIR /libslirp
ARG LIBSLIRP_COMMIT
RUN git pull && git checkout ${LIBSLIRP_COMMIT} && meson setup build && ninja -C build install
COPY . /slirp4netns
WORKDIR /slirp4netns
RUN chown -R 1000:1000 /slirp4netns
USER 1000:1000
RUN ./autogen.sh && ./configure && make -j $(nproc)
FROM build AS test
USER 0
RUN apt update && apt install -y git libtool iproute2 clang clang-format clang-tidy iputils-ping iperf3 nmap jq
USER 1000:1000
CMD ["make", "ci"]