Skip to content

Commit

Permalink
Improve docker build files
Browse files Browse the repository at this point in the history
* Update alpine to 3.19
* Build using docker build, without additional commands
* Make the result runnable
  • Loading branch information
orgads committed Jan 12, 2024
1 parent c9f6f0f commit c086db3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
name: sipp
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`.
Expand Down
29 changes: 26 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
51 changes: 34 additions & 17 deletions docker/Dockerfile.full
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c086db3

Please sign in to comment.