-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·177 lines (149 loc) · 6.31 KB
/
Dockerfile
File metadata and controls
executable file
·177 lines (149 loc) · 6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# syntax=docker/dockerfile:1.7
############################
# Builder stage
############################
FROM buildpack-deps:stable-scm AS builder
LABEL org.opencontainers.image.title="BitlBee container" \
org.opencontainers.image.description="A containerized version of BitlBee with additional plugins." \
org.opencontainers.image.url="https://github.com/mbologna/docker-bitlbee" \
org.opencontainers.image.licenses="MIT"
ARG BITLBEE_VERSION=3.6
ARG FACEBOOK_VERSION=1.2.2
ARG TARGETARCH
ENV DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
WORKDIR /build
# Build dependencies - grouped by functionality for better caching
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
# Build tools
autoconf automake build-essential cmake gcc git gperf libtool libtool-bin make pkg-config \
# Protocol libraries
libglib2.0-dev libhttp-parser-dev libotr5-dev libpurple-dev \
libgnutls28-dev libjson-glib-dev libnss3-dev libssl-dev libgcrypt20-dev libgcrypt-dev \
# Media libraries
libpng-dev libwebp-dev libgdk-pixbuf-xlib-2.0-dev libopusfile-dev \
librsvg2-bin imagemagick \
# Additional dependencies
libolm-dev libprotobuf-c-dev protobuf-c-compiler libqrencode-dev \
libmarkdown2-dev libsqlite3-dev \
# Utilities
netcat-traditional curl ca-certificates golang gettext sudo
# Fetch all sources in parallel where possible
RUN --mount=type=cache,target=/root/.cache/go-build \
curl -fsSL -o bitlbee.tar.gz https://get.bitlbee.org/src/bitlbee-${BITLBEE_VERSION}.tar.gz & \
curl -fsSL -o facebook.tar.gz https://github.com/bitlbee/bitlbee-facebook/archive/v${FACEBOOK_VERSION}.tar.gz & \
git clone --depth=1 --single-branch https://github.com/EionRobb/purple-discord.git & \
git clone --depth=1 --single-branch https://github.com/matrix-org/purple-matrix.git & \
git clone --depth=1 --single-branch https://github.com/EionRobb/purple-teams.git & \
git clone --depth=1 --single-branch https://github.com/dylex/slack-libpurple.git & \
git clone --depth=1 --single-branch https://github.com/BenWiederhake/tdlib-purple.git & \
git clone --depth=1 --single-branch https://github.com/kensanata/bitlbee-mastodon.git & \
git clone --depth=1 --single-branch --recurse-submodules --shallow-submodules \
https://github.com/hoehermann/purple-gowhatsapp.git purple-whatsmeow & \
wait
# Build BitlBee
RUN tar xf bitlbee.tar.gz
WORKDIR /build/bitlbee-${BITLBEE_VERSION}
RUN LDFLAGS="-lgcrypt" ./configure \
--jabber=1 \
--otr=1 \
--purple=1 \
--strip=1 \
--ssl=gnutls \
--systemdsystemunitdir=no && \
make -j"$(nproc)" && \
make install install-bin install-doc install-dev install-etc install-plugin-otr
WORKDIR /build
RUN tar xf facebook.tar.gz
WORKDIR /build/bitlbee-facebook-${FACEBOOK_VERSION}
RUN ./autogen.sh && \
make -j"$(nproc)" && \
make install
WORKDIR /build/purple-discord
RUN make -j"$(nproc)" && make install
WORKDIR /build/purple-matrix
RUN make -j"$(nproc)" && make install
WORKDIR /build/purple-teams
RUN make -j"$(nproc)" && make install
WORKDIR /build/slack-libpurple
RUN make install
WORKDIR /build/tdlib-purple
RUN ./build_and_install.sh
WORKDIR /build/bitlbee-mastodon
RUN ./autogen.sh && \
./configure && \
make -j"$(nproc)" && \
make install
WORKDIR /build
RUN cmake -S purple-whatsmeow -B whatsapp-build -DCMAKE_BUILD_TYPE=Release && \
cmake --build whatsapp-build && \
cmake --install whatsapp-build --strip
RUN ldconfig && libtool --finish /usr/local/lib/bitlbee
############################
# Runtime stage
############################
FROM debian:stable-slim
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies with cache mount
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -y --no-install-recommends \
libpurple0 libotr5 libssl3 libgnutls30 libgcrypt20 \
libglib2.0-0 libjson-glib-1.0-0 libprotobuf-c1 \
libhttp-parser2.9 libsqlite3-0 libopusfile0 \
libwebp7 libolm3 libqrencode4 \
libpng16-16 libgdk-pixbuf-2.0-0 \
libstdc++6 zlib1g ca-certificates \
netcat-openbsd tini && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copy binaries and libraries from builder
COPY --from=builder /usr/local/lib /usr/local/lib
COPY --from=builder /usr/local/sbin /usr/local/sbin
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/share /usr/local/share
COPY --from=builder /usr/local/etc /usr/local/etc
# Copy purple plugins and their dependencies
COPY --from=builder /usr/lib/*-linux-gnu/purple-2 /tmp/purple-2/
COPY --from=builder /usr/share/pixmaps/pidgin /usr/share/pixmaps/pidgin/
# Install purple plugins to correct architecture directory
RUN ARCH_DIR=$(ls -d /usr/lib/*-linux-gnu 2>/dev/null | head -n1) && \
mkdir -p "${ARCH_DIR}/purple-2" && \
if [ -d /tmp/purple-2 ]; then \
cp -a /tmp/purple-2/* "${ARCH_DIR}/purple-2/" && \
rm -rf /tmp/purple-2; \
fi && \
# Run ldconfig to update library cache
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr-local.conf && \
ldconfig && \
# Verify plugins were copied
ls -la "${ARCH_DIR}/purple-2/" || echo "Warning: No plugins found"
# Create bitlbee user and directories with proper permissions
RUN groupadd -r -g 1000 bitlbee && \
useradd --system --uid 1000 --gid 1000 \
--home-dir /var/lib/bitlbee \
--shell /usr/sbin/nologin \
--comment "BitlBee IRC Gateway" \
bitlbee && \
mkdir -p /var/lib/bitlbee /var/run && \
chown -R bitlbee:bitlbee /var/lib/bitlbee && \
touch /var/run/bitlbee.pid && \
chown bitlbee:bitlbee /var/run/bitlbee.pid && \
chmod 644 /var/run/bitlbee.pid
# Health check script
COPY --chmod=755 <<'EOF' /usr/local/bin/healthcheck.sh
#!/bin/sh
nc -z localhost 6667 || exit 1
EOF
VOLUME ["/var/lib/bitlbee"]
USER bitlbee
WORKDIR /var/lib/bitlbee
EXPOSE 6667
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD ["/usr/local/bin/healthcheck.sh"]
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/usr/local/sbin/bitlbee", "-F", "-n", "-v"]