diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..60e5099 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,49 @@ +# ---- Build stage ---- +FROM alpine:latest AS builder + +# Install build tools and dependencies +RUN apk add --no-cache \ + build-base \ + git \ + json-c-dev \ + libmnl-dev + +# --------------------------------- +# Build libsavl as a static library +# --------------------------------- +WORKDIR /deps +RUN git clone https://github.com/ipilcher/libsavl.git +WORKDIR /deps/libsavl +RUN mkdir -p /usr/local/include \ + && gcc -std=gnu99 -O3 -Wall -Wextra -c savl.c -o savl.o \ + && ar rcs libsavl.a savl.o \ + && cp libsavl.a /usr/local/lib/ \ + && cp savl.h /usr/local/include/ + +# --------------------------------- +# Build fdf +# --------------------------------- +WORKDIR /app +RUN git clone https://github.com/ipilcher/fdf.git . +WORKDIR /app + +# Link against static libsavl +RUN gcc -std=gnu99 -O3 -Wall -Wextra \ + -I/usr/local/include -I/usr/include/json-c \ + src/*.c \ + -L/usr/local/lib -lsavl -ljson-c -lmnl \ + -o fdfd + + +# ---- Runtime stage ---- +FROM alpine:latest + +# Runtime dependencies +RUN apk add --no-cache \ + json-c \ + libmnl \ + libstdc++ + +COPY --from=builder /app/fdfd /usr/local/bin/fdfd +ENTRYPOINT ["fdfd"] +CMD ["--help"] diff --git a/README.md b/README.md index f3dd1c7..b66d61b 100644 --- a/README.md +++ b/README.md @@ -570,3 +570,22 @@ Feb 26 17:33:49 asterisk.penurio.us fdfd[18317]: INFO: filter.c:214: Loaded filt Feb 26 17:33:49 asterisk.penurio.us fdfd[18317]: INFO: filter.c:214: Loaded filter (mdns_answe..." ] Hint: Some lines were ellipsized, use -l to show in full. ``` + +## Docker + +If you would like to run this as a container + +1. ```docker build -t fdf .``` +2. ```docker run --name fdf fdf``` + +```fdfd options: + -l | --syslog: log messages to syslog + -e | --stderr: log messages to stderr + -d | --debug: log debug level messages + -p | --pktlog: enable verbose packet logging + -c | --config: specify configuration file + -h | --help: show this message and exit +``` + +From there you may wish to pass arguments to the run command, run it through compose as a daemon, etc. +