Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building with system hiredis #378

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git
.gitignore
.dockerignore
Dockerfile
build-docker.sh
*.o
*.lo
*.la
**/build
**/.deps
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ jobs:
tags: ${{ steps.prepare_tag.outputs.image_id }}:${{ steps.prepare_tag.outputs.version }}
build-args: |
BUILD_CPUS=16
DETECTED_TAG=${{ steps.prepare_tag.outputs.tag }}
MYVERSION=${{ steps.prepare_tag.outputs.tag }}
push: true
no-cache: true
77 changes: 46 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,53 @@
FROM debian:bookworm-slim
FROM debian:bookworm-slim AS build
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
ca-certificates \
cmake \
curl \
g++ \
gcc \
git \
jq \
libboost-filesystem-dev \
libboost-log-dev \
libboost-system-dev \
libboost-thread-dev \
libcurl4-openssl-dev \
libgoogle-perftools-dev \
libhiredis-dev \
libssl-dev \
libtool \
libtool-bin \
make \
zlib1g-dev

ARG BUILD_CPUS=4
ARG DETECTED_TAG=main
WORKDIR /usr/local/src/drachtio-server
COPY . .
RUN ./bootstrap.sh
WORKDIR /usr/local/src/drachtio-server/build
ARG MYVERSION=1.0.0
RUN ../configure --enable-tcmalloc=yes CPPFLAGS='-DNDEBUG' CXXFLAGS='-O2'
RUN make -j$(nproc) MYVERSION=${MYVERSION}

FROM debian:bookworm-slim
RUN apt-get update \
&& apt-get -y --quiet --force-yes upgrade \
&& apt-get install -y --no-install-recommends ca-certificates gcc g++ make build-essential \
cmake git autoconf automake curl libtool libtool-bin libssl-dev libcurl4-openssl-dev zlib1g-dev \
libgoogle-perftools-dev jq libboost-all-dev \
&& git clone --depth=50 https://github.com/drachtio/drachtio-server.git /usr/local/src/drachtio-server \
&& cd /usr/local/src/drachtio-server \
&& git fetch --tags \
&& echo "checking out ${DETECTED_TAG}" \
&& git checkout ${DETECTED_TAG} \
&& git submodule update --init --recursive \
&& ./bootstrap.sh \
&& mkdir build \
&& cd build \
&& ../configure --enable-tcmalloc=yes CPPFLAGS='-DNDEBUG' CXXFLAGS='-O2' \
&& make -j${BUILD_CPUS} \
&& make install \
&& apt-get purge -y --quiet --auto-remove gcc g++ make cmake build-essential git libtool libtool-bin \
&& rm -rf /var/lib/apt/* \
&& rm -rf /var/lib/dpkg/* \
&& rm -rf /var/lib/cache/* \
&& rm -Rf /var/log/* \
&& rm -Rf /var/lib/apt/lists/* \
&& cd /usr/local/src \
&& cp drachtio-server/docker.drachtio.conf.xml /etc/drachtio.conf.xml \
&& cp drachtio-server/entrypoint.sh / \
&& rm -Rf drachtio-server \
&& cd /usr/local/bin \
&& rm -f timer ssltest parser uri_test test_https test_asio_curl
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
jq \
libboost-filesystem1.74.0 \
libboost-log1.74.0 \
libboost-system1.74.0 \
libboost-thread1.74.0 \
libgoogle-perftools4 \
libhiredis0.14 \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

COPY --from=build /usr/local/src/drachtio-server/build/drachtio /usr/local/bin/
COPY docker.drachtio.conf.xml /etc/drachtio.conf.xml
COPY ./entrypoint.sh /

VOLUME ["/config"]
Expand Down
13 changes: 12 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ drachtio_CPPFLAGS= -I${srcdir}/deps/sofia-sip/libsofia-sip-ua/su -I${srcdir}/dep
-D_REENTRANT -DBOOST_LOG_DYN_LINK -DDRACHTIO_VERSION=\"$(MYVERSION)\" -Wno-error=deprecated-declarations \
-DBOOST_ALLOW_DEPRECATED_HEADERS -O2

if DEP_HIREDIS
drachtio_CPPFLAGS += -I${srcdir}/deps
AM_LDFLAGS += -L${srcdir}/deps/hiredis
endif

drachtio_LDADD= ${srcdir}/deps/sofia-sip/libsofia-sip-ua/.libs/libsofia-sip-ua.a \
${srcdir}/deps/jansson/src/.libs/libjansson.a \
${srcdir}/deps/hiredis/libhiredis.a -lcurl -lpthread -lssl -lcrypto -lz
-lhiredis -lcurl -lpthread -lssl -lcrypto -lz

if LINUX
drachtio_CPPFLAGS += -Wno-stringop-overflow
Expand All @@ -54,6 +59,10 @@ endif
BUILT_SOURCES=${srcdir}/deps/sofia-sip/libsofia-sip-ua/.libs/libsofia-sip-ua.a \
${srcdir}/deps/jansson/src/.libs/libjansson.a ${srcdir}/deps/prometheus-cpp/build/lib/libprometheus-cpp-core.a

if DEP_HIREDIS
BUILT_SOURCES += ${srcdir}/deps/hiredis/libhiredis.a
endif

clean-local:

${srcdir}/deps/sofia-sip/libsofia-sip-ua/.libs/libsofia-sip-ua.a:
Expand All @@ -67,5 +76,7 @@ ${srcdir}/deps/prometheus-cpp/build/lib/libprometheus-cpp-core.a ${srcdir}/deps/
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX=`pwd` && \
$(MAKE) && make install

if DEP_HIREDIS
${srcdir}/deps/hiredis/libhiredis.a:
cd ${srcdir}/deps/hiredis && cmake -DBUILD_SHARED_LIBS=OFF -DENABLE_SSL=ON . && $(MAKE)
endif
3 changes: 3 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

docker build --build-arg MYVERSION=$(git describe --always) . "$@"
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AC_LANG(C++)
AX_CXX_COMPILE_STDCXX_11()
AX_CXX_COMPILE_STDCXX_17(noext, optional)

AM_CONDITIONAL([DEP_HIREDIS], [test -f "${srcdir}/deps/hiredis/CMakeLists.txt"])
AM_CONDITIONAL(OSX, false)
AM_CONDITIONAL(LINUX, false)

Expand Down
2 changes: 1 addition & 1 deletion src/blacklist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ THE SOFTWARE.
#include <boost/variant.hpp>
#include <regex>

#include "hiredis.h"
#include <hiredis/hiredis.h>

#include "blacklist.hpp"
#include "controller.hpp"
Expand Down
Loading