LeKovr / webtail

Tail logfile via websocket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request for ARMv7 docker builds for Raspberry

xorguy opened this issue · comments

Hi.

I've trying a bit to build the Docker image to armv7, to run under Raspberry Pi 3/4 with no luck so far, so if possible it will be handy to have the tool running under Raspberry.

Thanks.

Regards.

Hi, Daniel. Would you please provide me with some details about this "no luck"? Is it a build errors? Are they related to some package or app itself?

Hi.
I have not much experience with building dockers, before trying to cross compile for armv7 I tried to build locally changing line:
FROM golang:$GOLANG_VERSION as builder
to FROM golang:alpine as builder

with your original line any attempt with buildx failed

but then fails with:

Step 11/22 : RUN go install github.com/phogolabs/parcello/cmd/parcello
 ---> Running in b811244c5985
/go/pkg/mod/github.com/phogolabs/parcello@v0.8.2/cmd/parcello/main.go:13:2: missing go.sum entry for module providing package github.com/phogolabs/cli (imported by github.com/phogolabs/parcello/cmd/parcello); to add:
        go get github.com/phogolabs/parcello/cmd/parcello@v0.8.2
The command '/bin/sh -c go install github.com/phogolabs/parcello/cmd/parcello' returned a non-zero code: 1

Not sure if the error is on my side or with the repository of parcello, that just now I saw it is in read only and somehow deprecated.

Regards.

GOLANG_VERSION defined here as 1.15.5-alpine3.12

So you have upgraded golang version from 1.15 to (what version, 1.16? 1.17?) and met some errors. I guess this is normal and this is golang version update issue, not "ARMv7". What alpine version you want build for?

I did not intended to change golang version, I switched to alpine in DockerFile to see if that will help to build for armv7 and is a light distro.

I just wanted to build for arm7v so I can run the docker in my Raspberry Pi 4.

I'v added armv7 binary for current release. It this your point?

Thanks for the binary, I guess this can be integrated with a golang arm docker image.

I just found out this https://hub.docker.com/r/arm32v7/golang/ repository that have official golang for arm32v7.
I can try to join both binary and image. Maybe you can add as a tag at docker hub for following releases.

Maybe you can add as a tag at docker hub for following releases.

diff --git a/Dockerfile b/Dockerfile
index 586e225..08e2e75 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,7 @@
 ARG GOLANG_VERSION
 
 # FROM golang:$GOLANG_VERSION as builder
-FROM ghcr.io/dopos/golang-alpine:v1.16.10-alpine3.14.2 as builder
+FROM golang:1.16.10-alpine as builder
 ARG TARGETARCH
 
 WORKDIR /opt/app

take this diff and build your oun version of webtail:

pi@racedb400:~/webtail $ docker build -f Dockerfile . -t webtail:local
Sending build context to Docker daemon  1.053MB
Step 1/17 : ARG GOLANG_VERSION
Step 2/17 : FROM golang:1.16.10-alpine as builder
1.16.10-alpine: Pulling from library/golang
764d2e53e1a6: Pull complete 
9f548be3ae33: Pull complete 
053162e9c4e9: Pull complete 
2095417f039b: Pull complete 
4a03b7f34f89: Pull complete 
Digest: sha256:45412fe3f5016509fc448b83faefc34e6f9e9bcc8ca1db1c54505d5528264e16
Status: Downloaded newer image for golang:1.16.10-alpine
 ---> 803866474dab
Step 3/17 : ARG TARGETARCH
 ---> Running in b887a5cb766e
Removing intermediate container b887a5cb766e
 ---> ac89a0794831
Step 4/17 : WORKDIR /opt/app
 ---> Running in c72df918a0fd
Removing intermediate container c72df918a0fd
 ---> 6ae2bab59bb3
Step 5/17 : COPY ./go.mod ./go.sum ./
 ---> 803bd97bbb7c
Step 6/17 : RUN echo "Build for arch $TARGETARCH"
 ---> Running in 7f0eabb57f9a
Build for arch 
Removing intermediate container 7f0eabb57f9a
 ---> 38e8acfec595
Step 7/17 : COPY ./ ./
 ---> 4180537de320
Step 8/17 : RUN CGO_ENABLED=0 go test -tags test -covermode=atomic -coverprofile=coverage.out ./...
 ---> Running in 075a8a37fbb0
go: downloading github.com/go-logr/logr v0.3.0
go: downloading github.com/fukata/golang-stats-api-handler v1.0.0
go: downloading github.com/go-logr/zapr v0.3.0
go: downloading github.com/jessevdk/go-flags v1.3.1-0.20170926144705-f88afde2fa19
go: downloading github.com/mattn/go-colorable v0.1.8
go: downloading go.uber.org/zap v1.16.0
go: downloading github.com/stretchr/testify v1.6.1
go: downloading github.com/dc0d/dirwatch v0.4.3
go: downloading github.com/gorilla/websocket v1.4.2
go: downloading github.com/nxadm/tail v1.4.8
go: downloading github.com/a8m/djson v0.0.0-20170509170705-c02c5aef757f
go: downloading github.com/wojas/genericr v0.2.0
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/dc0d/retry v1.2.0
go: downloading github.com/fsnotify/fsnotify v1.4.9
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: downloading go.uber.org/atomic v1.6.0
go: downloading go.uber.org/multierr v1.5.0
go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: downloading golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae
ok  	github.com/LeKovr/webtail	1.088s	coverage: 86.9% of statements
ok  	github.com/LeKovr/webtail/cmd/webtail	0.524s	coverage: 100.0% of statements
Removing intermediate container 075a8a37fbb0
 ---> ba9ab0db594b
Step 9/17 : RUN CGO_ENABLED=0 go build -ldflags "-X main.version=`git describe --tags --always`" -a ./cmd/webtail
 ---> Running in f35c44e16ad3
/bin/sh: git: not found
Removing intermediate container f35c44e16ad3
 ---> 4415ee1e549e
Step 10/17 : FROM scratch
 ---> 
Step 11/17 : MAINTAINER Alexey Kovrizhkin <lekovr+dopos@gmail.com>
 ---> Running in 769eb24922ca
Removing intermediate container 769eb24922ca
 ---> b05a4d57ea28
Step 12/17 : LABEL org.opencontainers.image.description "Tail [log]files via web[sockets]"
 ---> Running in d9daa37e8bd8
Removing intermediate container d9daa37e8bd8
 ---> 654a0277cb4e
Step 13/17 : VOLUME /data
 ---> Running in e9f683e842df
Removing intermediate container e9f683e842df
 ---> cae782b79e9c
Step 14/17 : WORKDIR /
 ---> Running in d9cd1e252f74
Removing intermediate container d9cd1e252f74
 ---> e8e89993ec04
Step 15/17 : COPY --from=builder /opt/app/webtail .
 ---> 323cd2cba6d3
Step 16/17 : EXPOSE 8080
 ---> Running in 89acaf690c24
Removing intermediate container 89acaf690c24
 ---> 496e39fc507a
Step 17/17 : ENTRYPOINT ["/webtail"]
 ---> Running in 7514c82a0a48
Removing intermediate container 7514c82a0a48
 ---> 1235e9d65f3d
Successfully built 1235e9d65f3d
Successfully tagged webtail:local

racedb400:/opt/webtail.ds $ docker-compose up
Creating webtailds_app_1 ... done
Attaching to webtailds_app_1
app_1  | {"level":"info","ts":1637005243.9570744,"caller":"webtail/app.go:32","msg":"WebTail. Tail (log)files via web.","v":""}
app_1  | {"level":"info","ts":1637005243.9576,"caller":"webtail/app.go:44","msg":"Listen","addr":":8080"}
app_1  | {"level":"info","ts":1637005244.9140797,"caller":"app/indexer.go:96","msg":"Handling file event","event":{"Name":"/log/daemon.log","Op":2}}
app_1  | {"level":"info","ts":1637005244.9147964,"caller":"app/indexer.go:96","msg":"Handling file event","event":{"Name":"/log/daemon.log","Op":2}}
app_1  | {"level":"info","ts":1637005244.9151394,"caller":"app/indexer.go:96","msg":"Handling file event","event":{"Name":"/log/syslog","Op":2}}
app_1  | {"level":"info","ts":1637005244.9142997,"caller":"app/indexer.go:96","msg":"Handling file event","event":{"Name":"/log/syslog","Op":2}}
app_1  | {"level":"info","ts":1637005244.9166102,"caller":"app/indexer.go:96","msg":"Handling file event","event":{"Name":"/log/syslog","Op":2}}
app_1  | {"level":"info","ts":1637005244.9163146,"caller":"app/indexer.go:96","msg":"Handling file event","event":{"Name":"/log/daemon.log","Op":2}}
app_1  | {"level":"info","ts":1637005249.2452233,"caller":"app/indexer.go:96","msg":"Handling file event","event":{"Name":"/log/daemon.log","Op":2}}
app_1  | {"level":"info","ts":1637005249.2453895,"caller":"app/indexer.go:96","msg":"Handling file event","event":{"Name":"/log/syslog","Op":2}}

Also v0.46.1 have docker images for arm/v7, use docker pull ghcr.io/lekovr/webtail:v0.46.1