FROM alpine AS builder
RUN apk --no-cache add build-base cmake linux-headers boost-dev boost-static

WORKDIR /usr/src/app
COPY CMakeLists.txt src/ ./
RUN cmake --build .

FROM alpine
RUN apk --no-cache add libgcc libstdc++ bash iproute2 iptables ipset netcat-openbsd
COPY --from=builder /usr/src/app/tun /usr/local/bin/
COPY ./entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["tun"]
