mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 04:07:07 +00:00
76 lines
2.9 KiB
Docker
76 lines
2.9 KiB
Docker
FROM golang:1.24-bookworm AS base
|
|
|
|
RUN apt-get update
|
|
RUN apt-get install -y libssl-dev cmake build-essential gperf libz-dev make git php libsignal-protocol-c-dev
|
|
|
|
FROM base AS tdlib
|
|
|
|
ARG TD_COMMIT
|
|
ARG MAKEOPTS
|
|
RUN git clone https://github.com/tdlib/td /src/
|
|
RUN git -C /src/ checkout "${TD_COMMIT}"
|
|
RUN mkdir build
|
|
WORKDIR /build/
|
|
RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/compiled/ /src/
|
|
RUN cmake --build . --target prepare_cross_compiling ${MAKEOPTS}
|
|
WORKDIR /src/
|
|
RUN php SplitSource.php
|
|
WORKDIR /build/
|
|
RUN cmake --build . ${MAKEOPTS}
|
|
RUN make install
|
|
|
|
FROM base AS ntgcalls-build
|
|
ARG MAKEOPTS
|
|
# CMake >= 3.27 required; bookworm ships 3.25
|
|
ARG CMAKE_VERSION=3.31.6
|
|
RUN curl -fsSL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(uname -m).tar.gz \
|
|
| tar xz -C /usr/local --strip-components=1
|
|
RUN apt-get install -y libasound2-dev libpulse-dev
|
|
# Note: ntgcalls submodule must be initialized on host before docker build
|
|
RUN --mount=type=bind,source=./ntgcalls,target=/ntgcalls-src,rw \
|
|
mkdir -p /ntgcalls-build && cd /ntgcalls-build && \
|
|
cmake -DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_TOOLCHAIN_FILE=/ntgcalls-src/cmake/Toolchain.cmake \
|
|
-DPython_EXECUTABLE=$(which python3) \
|
|
-DSTATIC_BUILD=ON \
|
|
/ntgcalls-src/ && \
|
|
cmake --build . ${MAKEOPTS} && \
|
|
cp -r /ntgcalls-src/static-output /ntgcalls-output
|
|
|
|
FROM base AS cache
|
|
ARG VERSION
|
|
COPY --from=tdlib /compiled/ /usr/local/
|
|
COPY --from=ntgcalls-build /ntgcalls-output/lib/libntgcalls.a /usr/local/lib/
|
|
COPY --from=ntgcalls-build /ntgcalls-output/include/ /usr/local/include/
|
|
RUN --mount=type=bind,source=./docker/resolv_shim.c,target=/tmp/resolv_shim.c \
|
|
gcc -c -o /tmp/resolv_shim.o /tmp/resolv_shim.c && \
|
|
ar rcs /usr/local/lib/libresolv_shim.a /tmp/resolv_shim.o
|
|
WORKDIR /src
|
|
RUN go env -w GOCACHE=/go-cache
|
|
RUN go env -w GOMODCACHE=/gomod-cache
|
|
# Note: submodules must be initialized on host before docker build (bind mount)
|
|
RUN --mount=type=cache,target=/gomod-cache \
|
|
--mount=type=bind,source=./,target=/src,rw \
|
|
/bin/bash -c 'go mod tidy; go get'
|
|
|
|
FROM cache AS build
|
|
ARG MAKEOPTS
|
|
ENV CGO_ENABLED=1
|
|
ENV CGO_CFLAGS="-I/usr/local/include"
|
|
ENV CGO_LDFLAGS="-L/usr/local/lib -lntgcalls -lresolv_shim -lstdc++ -lm -ldl -lrt -lpthread -lz -lresolv"
|
|
WORKDIR /src
|
|
# Bullseye only has the pre-fork libsignal-protocol-c packaged (libomemo-c
|
|
# is bookworm+) - GOTAGS=signal_legacy builds telegabber's OMEMO bindings
|
|
# against it, which only supports legacy/siacs OMEMO, not modern OMEMO 1/2.
|
|
RUN --mount=type=bind,source=./,target=/src,rw \
|
|
--mount=type=cache,target=/go-cache \
|
|
--mount=type=cache,target=/gomod-cache \
|
|
--mount=type=cache,destination=/src/release \
|
|
make ${MAKEOPTS} GOTAGS=signal_legacy
|
|
|
|
FROM build AS release
|
|
RUN --mount=type=cache,destination=/src/release \
|
|
cp /src/release/telegabber /
|
|
|
|
FROM scratch AS binaries
|
|
COPY --from=release /telegabber /
|