Skip to content

Commit 88393b1

Browse files
committed
Improve docker build
* Use current code instead of cloning from github. * Use multi-stage instead of deleting everything.
1 parent 1e44181 commit 88393b1

File tree

3 files changed

+55
-24
lines changed

3 files changed

+55
-24
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
.gitignore
3+
.dockerignore
4+
Dockerfile
5+
*.o
6+
*.lo
7+
*.la
8+
**/build
9+
**/.deps

Dockerfile

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,49 @@
1-
FROM debian:bullseye-slim
1+
FROM debian:bookworm-slim AS build
2+
RUN apt-get update \
3+
&& apt-get -y --quiet upgrade \
4+
&& apt-get install -y --no-install-recommends \
5+
autoconf \
6+
automake \
7+
build-essential \
8+
ca-certificates \
9+
cmake \
10+
curl \
11+
g++ \
12+
gcc \
13+
git \
14+
libboost-filesystem-dev \
15+
libboost-log-dev \
16+
libboost-system-dev \
17+
libboost-thread-dev \
18+
libcurl4-openssl-dev \
19+
libgoogle-perftools-dev \
20+
libssl-dev \
21+
libtool \
22+
libtool-bin \
23+
make \
24+
zlib1g-dev
25+
26+
WORKDIR /usr/local/src/drachtio-server
27+
COPY . .
28+
RUN ./bootstrap.sh
29+
WORKDIR /usr/local/src/drachtio-server/build
30+
ARG MYVERSION=1.0.0
31+
RUN ../configure --enable-tcmalloc=yes CPPFLAGS='-DNDEBUG' CXXFLAGS='-O2'
32+
RUN make -j$(nproc) MYVERSION=${VERSION}
233

34+
FROM debian:bookworm-slim
335
RUN apt-get update \
4-
&& apt-get -y --quiet --force-yes upgrade \
5-
&& 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 \
6-
&& git clone --depth=50 --branch=main https://github.com/drachtio/drachtio-server.git /usr/local/src/drachtio-server \
7-
&& cd /usr/local/src/drachtio-server \
8-
&& git submodule update --init --recursive \
9-
&& ./bootstrap.sh \
10-
&& mkdir /usr/local/src/drachtio-server/build \
11-
&& cd /usr/local/src/drachtio-server/build \
12-
&& ../configure --enable-tcmalloc=yes CPPFLAGS='-DNDEBUG' CXXFLAGS='-O2' \
13-
&& make \
14-
&& make install \
15-
&& apt-get purge -y --quiet --auto-remove gcc g++ make cmake build-essential git autoconf automake libtool libtool-bin \
16-
&& rm -rf /var/lib/apt/* \
17-
&& rm -rf /var/lib/dpkg/* \
18-
&& rm -rf /var/lib/cache/* \
19-
&& rm -Rf /var/log/* \
20-
&& rm -Rf /var/lib/apt/lists/* \
21-
&& cd /usr/local/src \
22-
&& cp drachtio-server/docker.drachtio.conf.xml /etc/drachtio.conf.xml \
23-
&& cp drachtio-server/entrypoint.sh / \
24-
&& rm -Rf drachtio-server \
25-
&& cd /usr/local/bin \
26-
&& rm -f timer ssltest parser uri_test test_https test_asio_curl
36+
&& apt-get -y --quiet upgrade \
37+
&& apt-get install -y --no-install-recommends \
38+
ca-certificates \
39+
curl \
40+
libboost-filesystem1.74.0 \
41+
libboost-log1.74.0 \
42+
libboost-system1.74.0 \
43+
libboost-thread1.74.0 \
44+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
2745

46+
COPY --from=build /usr/local/src/drachtio-server/build/drachtio /usr/local/bin/
2847
COPY ./entrypoint.sh /
2948

3049
VOLUME ["/config"]

build-docker.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
docker build --build-arg VERSION=$(git describe --always) .

0 commit comments

Comments
 (0)