diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index be715456..00000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM golang:1-alpine3.19 AS builder - -RUN apk add --no-cache git ca-certificates build-base su-exec olm-dev - -COPY . /build -WORKDIR /build -RUN go build -o /usr/bin/mautrix-telegram - -FROM alpine:3.19 - -ENV UID=1337 \ - GID=1337 - -RUN apk add --no-cache ffmpeg su-exec ca-certificates olm bash jq yq curl - -COPY --from=builder /usr/bin/mautrix-telegram /usr/bin/mautrix-telegram -COPY --from=builder /build/example-config.yaml /opt/mautrix-telegram/example-config.yaml -COPY --from=builder /build/docker-run.sh /docker-run.sh -VOLUME /data - -CMD ["/docker-run.sh"] diff --git a/Dockerfile.ci b/Dockerfile.ci deleted file mode 100644 index ba34e1f9..00000000 --- a/Dockerfile.ci +++ /dev/null @@ -1,14 +0,0 @@ -FROM alpine:3.19 - -ENV UID=1337 \ - GID=1337 - -RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq - -ARG EXECUTABLE=./mautrix-telegram -COPY $EXECUTABLE /usr/bin/mautrix-telegram -COPY ./example-config.yaml /opt/mautrix-telegram/example-config.yaml -COPY ./docker-run.sh /docker-run.sh -VOLUME /data - -CMD ["/docker-run.sh"] diff --git a/build.sh b/build.sh index a8901bc5..c43ddd5b 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +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-telegram "$@" +MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }' | head -n1) +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 -Iseconds`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'" +go build -ldflags="$GO_LDFLAGS" ./cmd/mautrix-telegram "$@" diff --git a/docker-run.sh b/docker-run.sh index e7682441..30f1fdc3 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -4,7 +4,8 @@ if [[ -z "$GID" ]]; then GID="$UID" fi -# Define functions. +BINARY_NAME=/usr/bin/mautrix-telegram + function fixperms { chown -R $UID:$GID /data @@ -15,7 +16,7 @@ function fixperms { } if [[ ! -f /data/config.yaml ]]; then - cp /opt/mautrix-telegram/example-config.yaml /data/config.yaml + $BINARY_NAME -c /data/config.yaml -e echo "Didn't find a config file." echo "Copied default config file to /data/config.yaml" echo "Modify that config file to your liking." @@ -24,7 +25,7 @@ if [[ ! -f /data/config.yaml ]]; then fi if [[ ! -f /data/registration.yaml ]]; then - /usr/bin/mautrix-telegram -g -c /data/config.yaml -r /data/registration.yaml || exit $? + $BINARY_NAME -g -c /data/config.yaml -r /data/registration.yaml echo "Didn't find a registration file." echo "Generated one for you." echo "See https://docs.mau.fi/bridges/general/registering-appservices.html on how to use it." @@ -33,4 +34,4 @@ fi cd /data fixperms -exec su-exec $UID:$GID /usr/bin/mautrix-telegram +exec su-exec $UID:$GID $BINARY_NAME