Skip to content

Commit

Permalink
Improve docker build files
Browse files Browse the repository at this point in the history
* Update alpine to 3.18
* Build using docker build, without additional commands
* Make the result runnable
  • Loading branch information
orgads committed Aug 30, 2023
1 parent 1126a8b commit 3c1af2f
Show file tree
Hide file tree
Showing 4 changed files with 62 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 @@ -70,8 +70,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 .
```

# Support
Expand Down Expand Up @@ -104,8 +103,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
sudo docker build -t sipp -f docker/Dockerfile .
```
* Note that the static build is broken at the moment. See `ldd sipp`.
Expand Down
35 changes: 32 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
FROM alpine:3.10
# Usage (from within the git repo):
# git submodule update --init
# docker build -t sipp -f docker/Dockerfile .

RUN apk add --no-cache binutils make cmake gcc g++ ncurses-static libpcap-dev ncurses-dev gsl-dev git
FROM alpine:3.18 AS build

CMD cd /src && rm -f CMakeCache.txt && cmake . -DBUILD_STATIC=1 -DUSE_PCAP=1 -DUSE_GSL=1 && make
RUN apk add --no-cache \
binutils \
cmake \
g++ \
gcc \
git \
gsl-dev \
gsl-static \
libpcap-dev \
make \
ncurses-dev \
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 -DBUILD_STATIC=1 -DUSE_PCAP=1 -DUSE_GSL=1
RUN ninja

FROM scratch AS bin
COPY --from=build /sipp/sipp /sipp

FROM alpine:3.18
CMD ["sipp"]
COPY --from=build /sipp/sipp /usr/local/bin/sipp
44 changes: 27 additions & 17 deletions docker/Dockerfile.full
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
FROM alpine:3.13
# Usage (from within the git repo):
# git submodule update --init
# docker build -t sipp:full -f docker/Dockerfile.full .

FROM alpine:3.18 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 -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.18
CMD ["sipp"]
COPY --from=build /sipp/sipp /usr/local/bin/sipp

0 comments on commit 3c1af2f

Please sign in to comment.