Compare commits

...

6 commits

Author SHA1 Message Date
Andrew Ferrazzutti eb0f2d0177
Merge 6022f88105 into f8a22aab06 2024-02-19 12:56:59 +01:00
Andrew Ferrazzutti 6022f88105 Print debug mode in Docker build
This allows the build cache to be invalidated when DBGWAIT is set
2024-02-05 13:18:34 -05:00
Andrew Ferrazzutti 8194cd907a Use sh/POSIX expressions 2024-02-05 10:53:46 -05:00
Andrew Ferrazzutti 1c641e2f1c Use heredoc 2024-02-05 10:53:46 -05:00
Andrew Ferrazzutti 613c35fa5b Omit debug info on release build 2024-02-05 10:53:46 -05:00
Andrew Ferrazzutti 6b2a89913c Allow debug build & remote debugging 2024-02-05 10:53:46 -05:00
4 changed files with 38 additions and 4 deletions

View file

@ -4,7 +4,15 @@ 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-whatsapp
ARG DBG=0
RUN <<EOF
if [ "$DBG" = 1 ]; then
go install github.com/go-delve/delve/cmd/dlv@latest
else
touch /go/bin/dlv
fi
EOF
RUN ./build.sh -o /usr/bin/mautrix-whatsapp
FROM alpine:3.19
@ -16,6 +24,11 @@ RUN apk add --no-cache ffmpeg su-exec ca-certificates olm bash jq yq curl
COPY --from=builder /usr/bin/mautrix-whatsapp /usr/bin/mautrix-whatsapp
COPY --from=builder /build/example-config.yaml /opt/mautrix-whatsapp/example-config.yaml
COPY --from=builder /build/docker-run.sh /docker-run.sh
COPY --from=builder /go/bin/dlv /usr/bin/dlv
VOLUME /data
ARG DBG
ARG DBGWAIT=0
ENV DBG=${DBG} DBGWAIT=${DBGWAIT}
RUN echo "Debug mode: DBG=${DBG} DBGWAIT=${DBGWAIT}"
CMD ["/docker-run.sh"]

View file

@ -4,7 +4,13 @@ RUN apk add --no-cache git ca-certificates build-base su-exec olm-dev bash jq yq
COPY . /build
WORKDIR /build
RUN go build -o /whatsapp
ARG DBG=0
if [ "$DBG" = 1 ]; then
go install github.com/go-delve/delve/cmd/dlv@latest
else
touch /go/bin/dlv
fi
RUN ./build.sh -o /mautrix-whatsapp
# Setup development stack using gow
RUN go install github.com/mitranim/gow@latest

View file

@ -1,2 +1,7 @@
#!/bin/sh
go build -ldflags "-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'`'" "$@"
if [ "$DBG" = 1 ]; then
GO_GCFLAGS='all=-N -l'
else
GO_LDFLAGS="-s -w ${GO_LDFLAGS}"
fi
go build -gcflags="$GO_GCFLAGS" -ldflags="-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'`'" "$@"

View file

@ -33,4 +33,14 @@ fi
cd /data
fixperms
exec su-exec $UID:$GID /usr/bin/mautrix-whatsapp
EXE=/usr/bin/mautrix-whatsapp
DLV=/usr/bin/dlv
if [ -x "$DLV" ]; then
if [ "$DBGWAIT" != 1 ]; then
NOWAIT=1
fi
EXE="${DLV} exec ${EXE} ${NOWAIT:+--continue --accept-multiclient} --api-version 2 --headless -l :4040"
fi
exec su-exec $UID:$GID $EXE