-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,44 @@ | ||
# -- Build libsignal (with Rust) -- | ||
FROM rust:1.70.0-slim as rust-builder | ||
RUN apt-get update && apt-get install -y --no-install-recommends make cmake clang llvm protobuf-compiler | ||
FROM rust:1-alpine as rust-builder | ||
RUN apk add --no-cache git make cmake protoc musl-dev g++ clang-dev | ||
|
||
WORKDIR /build | ||
# Copy all files needed for Rust build, and no Go files | ||
COPY pkg/libsignalgo/libsignal/. pkg/libsignalgo/libsignal/. | ||
COPY Makefile . | ||
|
||
ARG DBG=0 | ||
RUN make build_rust | ||
RUN make copy_library | ||
ENV RUSTFLAGS="-Ctarget-feature=-crt-static" RUSTC_WRAPPER="" | ||
RUN cd pkg/libsignalgo/libsignal/ && cargo build -p libsignal-ffi --release | ||
|
||
# -- Build mautrix-signal (with Go) -- | ||
FROM golang:1.20-bookworm AS go-builder | ||
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates libolm-dev | ||
|
||
ARG DBG=0 | ||
RUN /bin/bash -c 'if [[ $DBG -eq 1 ]]; then go install github.com/go-delve/delve/cmd/dlv@latest; else touch /go/bin/dlv; fi' | ||
FROM golang:1-alpine3.19 AS go-builder | ||
RUN apk add --no-cache git ca-certificates build-base olm-dev | ||
|
||
WORKDIR /build | ||
# Copy all files needed for Go build, and no Rust files | ||
COPY *.go go.* *.yaml ./ | ||
COPY *.go go.* *.yaml *.sh ./ | ||
COPY pkg/signalmeow/. pkg/signalmeow/. | ||
COPY pkg/libsignalgo/* pkg/libsignalgo/ | ||
COPY pkg/libsignalgo/resources/. pkg/libsignalgo/resources/. | ||
COPY config/. config/. | ||
COPY database/. database/. | ||
COPY msgconv/. msgconv/. | ||
COPY .git .git | ||
COPY Makefile . | ||
COPY docker-run.sh . | ||
|
||
COPY --from=rust-builder /build/libsignal_ffi.a /build/libsignal_ffi.a | ||
RUN make build_go | ||
ENV LIBRARY_PATH=. | ||
COPY --from=rust-builder /build/pkg/libsignalgo/libsignal/target/release/libsignal_ffi.a /build/libsignal_ffi.a | ||
RUN ./build-go.sh | ||
|
||
# -- Run mautrix-signal -- | ||
FROM debian:12-slim | ||
FROM alpine:3.19 | ||
|
||
ENV UID=1337 \ | ||
GID=1337 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates libolm-dev bash jq yq curl gosu && rm -rf /var/li/apt/lists/* | ||
RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq olm | ||
|
||
COPY --from=go-builder /build/mautrix-signal /usr/bin/mautrix-signal | ||
COPY --from=go-builder /build/example-config.yaml /opt/mautrix-signal/example-config.yaml | ||
COPY --from=go-builder /build/docker-run.sh /docker-run.sh | ||
COPY --from=go-builder /go/bin/dlv /usr/bin/dlv | ||
VOLUME /data | ||
|
||
ARG DBGWAIT=0 | ||
ENV DBGWAIT=${DBGWAIT} | ||
CMD ["/docker-run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
export MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }') | ||
export GO_LDFLAGS="-s -w -X main.Tag=$(git describe --exact-match --tags 2>/dev/null) -X main.Commit=$(git rev-parse HEAD) -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'" | ||
go build -ldflags "$GO_LDFLAGS" -o mautrix-signal |