e42.uk Circle Device

 

Quick Reference

whatsmeow on Alpine Linux in Docker

whatsmeow on Alpine Linux in Docker

Step by Step, ultra-simple and boring installation:

docker run -it golang:alpine3.18 /bin/ash

Install git and rlwrap (readline wrap)

apk --no-cache add git rlwrap gcc musl-dev sqlite-dev

cgo is required for sqlite and gcc is required for cgo and musl-dev is required for dev :-)

Shallow clone the whatsmeow repository

git clone --depth 1 https://github.com/tulir/whatsmeow

Go to the mdtest/ directory and build it with go

cd whatsmeow/mdtest
CGO_ENABLED=1 go build .

Then run it:

rlwrap ./mdtest

Authenticate

Add a device on your whatsapp app and scan the QR code to authenticate.

Quitting

Control-C then exit the shell

Starting it Again

Find the name of the container (a random name will be assigned by docker) it will have Exited now since it terminated in "Quitting":

docker ps -a

Start the container interactively:

docker start -i fervent_franklin

Go to the correct directory and run the application again

cd whatsmeow/mdtest
rlwrap ./mdtest

This time the application should use the previously stored authentication details to login to whatsapp.

Further Work

You might have guessed that this is quite inefficient since the result is an image with gcc and all the dev headers that were required when building but are not required to execute mdtest.

Infact very little is required now to execute mdtest and so a much smaller container may be used. The location of mdtest:

ls $(docker inspect fervent_franklin -f '{{.GraphDriver.Data.MergedDir}}')/go/whatsmeow/mdtest

Copy it out and it will probably work on the host, if not can be copied into another Alpine container with SQLite libs and rlwrap. No need for the golang container.

Further experimentation is left to the reader :-)

References

Quick Links: Techie Stuff | General | Personal | Quick Reference