diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index a8c55f68..57cb2c47 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -50,7 +50,7 @@ jobs: - name: prepare run: git submodule update --init - name: build-static - run: sudo docker build -t sipp-build docker && sudo docker run -v $PWD:/src sipp-build + run: docker build -f docker/Dockerfile --output=. --target=bin . - uses: actions/upload-artifact@v4.0.0 with: name: sipp diff --git a/README.md b/README.md index f2d7b9a1..462a6a49 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,7 @@ the following commands: ``` git submodule update --init -docker build -t sipp-build -f docker/Dockerfile docker -docker run --rm -v $PWD:/src sipp-build +docker build -t sipp -f docker/Dockerfile --output=. --target=bin . ``` # Support @@ -100,8 +99,7 @@ list](https://lists.sourceforge.net/lists/listinfo/sipp-users). (for ~rcX) with a period. * Create a static binary and upload this to github as well: ``` - sudo docker build -t sipp-build docker && - sudo docker run -it -v $PWD:/src sipp-build + docker build -t sipp -f docker/Dockerfile --output=. --target=bin . ``` * Note that the static build is broken at the moment. See `ldd sipp`. diff --git a/docker/Dockerfile b/docker/Dockerfile index 5533b9cb..c7725758 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,8 @@ -FROM alpine:3.18 +# Usage (from within the git repo): +# git submodule update --init +# docker build -t sipp -f docker/Dockerfile . + +FROM alpine:3.19 AS build RUN apk add --no-cache \ binutils \ @@ -11,6 +15,25 @@ RUN apk add --no-cache \ libpcap-dev \ make \ ncurses-dev \ - ncurses-static + ncurses-static \ + ninja + +WORKDIR /sipp +COPY CMakeLists.txt ./ +COPY src src +COPY include include +COPY gtest gtest +RUN --mount=type=bind,target=.git,source=.git \ + cmake . -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_STATIC=1 \ + -DUSE_PCAP=1 \ + -DUSE_GSL=1 +RUN ninja + +FROM scratch AS bin +COPY --from=build /sipp/sipp /sipp -CMD cd /src && rm -f CMakeCache.txt && cmake . -DBUILD_STATIC=1 -DUSE_PCAP=1 -DUSE_GSL=1 && make +FROM alpine:3.19 +CMD ["sipp"] +COPY --from=build /sipp/sipp /usr/local/bin/sipp diff --git a/docker/Dockerfile.full b/docker/Dockerfile.full index 1f790758..b5ed18cb 100644 --- a/docker/Dockerfile.full +++ b/docker/Dockerfile.full @@ -1,29 +1,46 @@ -FROM alpine:3.18 +# Usage (from within the git repo): +# git submodule update --init +# docker build -t sipp:full -f docker/Dockerfile.full . + +FROM alpine:3.19 AS build RUN apk add --no-cache \ binutils \ - make \ cmake \ - gcc \ g++ \ + gcc \ git \ - ncurses-dev \ - ncurses-static \ - libpcap-dev \ gsl-dev \ gsl-static \ - openssl-dev \ - openssl-libs-static \ + libpcap-dev \ linux-headers \ lksctp-tools-dev \ - lksctp-tools-static + lksctp-tools-static \ + make \ + ncurses-dev \ + ncurses-static \ + ninja \ + openssl-dev \ + openssl-libs-static -CMD cd /src \ - && rm -f CMakeCache.txt \ - && cmake . -DBUILD_STATIC=1 -DUSE_PCAP=1 -DUSE_GSL=1 -DUSE_SSL=1 -DUSE_SCTP=1 \ - && make +WORKDIR /sipp +COPY CMakeLists.txt ./ +COPY src src +COPY include include +COPY gtest gtest +RUN --mount=type=bind,target=.git,source=.git \ + cmake . -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_STATIC=1 \ + -DUSE_PCAP=1 \ + -DUSE_GSL=1 \ + -DUSE_SSL=1 \ + -DUSE_SCTP=1 +RUN ninja -# Usage (from within the git repo): -# git submodule update --init -# docker build -t sipp-build -f docker/Dockerfile.full docker -# docker run -v $PWD:/src sipp-build +FROM scratch AS bin +COPY --from=build /sipp/sipp /sipp + +FROM alpine:3.19 +CMD ["sipp"] +COPY --from=build /sipp/sipp /usr/local/bin/sipp