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

Improve docker build #294

Open
wants to merge 1 commit 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
75 changes: 44 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,51 @@
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 \
libboost-filesystem-dev \
libboost-log-dev \
libboost-system-dev \
libboost-thread-dev \
libcurl4-openssl-dev \
libgoogle-perftools-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 \
&& 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
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) . "$@"
Loading