Skip to content

Commit

Permalink
Improve docker build
Browse files Browse the repository at this point in the history
* Use current code instead of cloning from github.
* Use multi-stage instead of deleting everything.
  • Loading branch information
orgads committed Jun 29, 2023
1 parent 1e44181 commit fc0ad4b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 24 deletions.
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
67 changes: 43 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
FROM debian:bullseye-slim
FROM debian:bookworm-slim AS build
RUN apt-get update \
&& apt-get -y --quiet upgrade \
&& 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

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=${VERSION}

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 \
&& git clone --depth=50 --branch=main https://github.com/drachtio/drachtio-server.git /usr/local/src/drachtio-server \
&& cd /usr/local/src/drachtio-server \
&& git submodule update --init --recursive \
&& ./bootstrap.sh \
&& mkdir /usr/local/src/drachtio-server/build \
&& cd /usr/local/src/drachtio-server/build \
&& ../configure --enable-tcmalloc=yes CPPFLAGS='-DNDEBUG' CXXFLAGS='-O2' \
&& make \
&& make install \
&& apt-get purge -y --quiet --auto-remove gcc g++ make cmake build-essential git autoconf automake 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 -y --quiet upgrade \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
libboost-filesystem1.74.0 \
libboost-log1.74.0 \
libboost-system1.74.0 \
libboost-thread1.74.0 \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

COPY --from=build /usr/local/src/drachtio-server/build/drachtio /usr/local/bin/
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 VERSION=$(git describe --always) .

0 comments on commit fc0ad4b

Please sign in to comment.