From 30eca95c38d3b2f54b0b0957b65e3591a41cbd44 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sat, 14 Sep 2024 23:48:11 +0300 Subject: [PATCH] Consolidate Dockerfiles --- README.md | 9 +++++--- docker/Dockerfile | 13 +++++++++--- docker/Dockerfile.full | 47 ------------------------------------------ 3 files changed, 16 insertions(+), 53 deletions(-) delete mode 100644 docker/Dockerfile.full diff --git a/README.md b/README.md index 02396c6a..dd115724 100644 --- a/README.md +++ b/README.md @@ -60,15 +60,18 @@ and for now, it only works on Alpine Linux. To build a static binary, pass `-DBUILD_STATIC=1` to cmake. -Two Alpine-based `Dockerfile`s are provided, which can be used as a -build-environment. Use either `Dockerfile` or `Dockerfile.full` in -the following commands: +An Alpine-based `Dockerfile` is provided, which can be used as a +build-environment. Build with the following commands: ``` git submodule update --init docker build -t sipp -f docker/Dockerfile --output=. --target=bin . ``` +Special arguments can be passed with `--build-arg`: +* `FULL=1` - build all optional components +* `DEBUG=1` - build with debug symbols + # Support I try and be responsive to issues raised on Github, and there's [a diff --git a/docker/Dockerfile b/docker/Dockerfile index 3c1e0541..cf32e902 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,6 +4,8 @@ FROM alpine:3.20 AS build +ARG FULL='' + RUN apk add --no-cache \ binutils \ cmake \ @@ -16,21 +18,26 @@ RUN apk add --no-cache \ make \ ncurses-dev \ ncurses-static \ - ninja + ninja \ + ${FULL:+linux-headers lksctp-tools-dev lksctp-tools-static openssl-dev openssl-libs-static} WORKDIR /sipp COPY CMakeLists.txt ./ COPY src src COPY include include COPY gtest gtest + +ARG DEBUG='' RUN --mount=type=bind,target=.git,source=.git \ git config --global --add safe.directory /sipp && \ cmake . -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DBUILD_STATIC=1 \ -DUSE_PCAP=1 \ - -DUSE_GSL=1 && \ - ninja + -DUSE_GSL=1 \ + ${DEBUG:+-DDEBUG=1} \ + ${FULL:+-DUSE_SSL=1 -DUSE_SCTP=1} \ + && ninja FROM scratch AS bin COPY --from=build /sipp/sipp /sipp diff --git a/docker/Dockerfile.full b/docker/Dockerfile.full deleted file mode 100644 index 1217afe9..00000000 --- a/docker/Dockerfile.full +++ /dev/null @@ -1,47 +0,0 @@ -# Usage (from within the git repo): -# git submodule update --init -# docker build -t sipp:full -f docker/Dockerfile.full . - -FROM alpine:3.20 AS build - -RUN apk add --no-cache \ - binutils \ - cmake \ - g++ \ - gcc \ - git \ - gsl-dev \ - gsl-static \ - libpcap-dev \ - linux-headers \ - lksctp-tools-dev \ - lksctp-tools-static \ - make \ - ncurses-dev \ - ncurses-static \ - ninja \ - openssl-dev \ - openssl-libs-static - -WORKDIR /sipp -COPY CMakeLists.txt ./ -COPY src src -COPY include include -COPY gtest gtest -RUN --mount=type=bind,target=.git,source=.git \ - git config --global --add safe.directory /sipp && \ - cmake . -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_STATIC=1 \ - -DUSE_PCAP=1 \ - -DUSE_GSL=1 \ - -DUSE_SSL=1 \ - -DUSE_SCTP=1 && \ - ninja - -FROM scratch AS bin -COPY --from=build /sipp/sipp /sipp - -FROM alpine:3.20 -CMD ["sipp"] -COPY --from=build /sipp/sipp /usr/local/bin/sipp