Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic while trying to run cross compiled binary on Raspberry PI #254

Closed
quaintdev opened this issue Jun 7, 2020 · 5 comments · Fixed by #365
Closed

Panic while trying to run cross compiled binary on Raspberry PI #254

quaintdev opened this issue Jun 7, 2020 · 5 comments · Fixed by #365
Labels

Comments

@quaintdev
Copy link

quaintdev commented Jun 7, 2020

Cross compiled binary for Raspberry PI panics on device with following error

panic: Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work.

goroutine 1 [running]:
github.com/jmoiron/sqlx.MustConnect(...)
	/home/user/go/pkg/mod/github.com/jmoiron/sqlx@v1.2.0/sqlx.go:650
github.com/go-shiori/shiori/internal/database.OpenSQLiteDatabase(0x2776000, 0x26, 0x0, 0x0, 0x0)
	/home/user/go/src/github.com/go-shiori/shiori/internal/database/sqlite.go:23 +0x384
github.com/go-shiori/shiori/internal/cmd.openSQLiteDatabase(0x5834d9, 0xb, 0x0, 0x0)
	/home/user/go/src/github.com/go-shiori/shiori/internal/cmd/root.go:116 +0x70
github.com/go-shiori/shiori/internal/cmd.openDatabase(0x27600a0, 0x1c, 0x1ff, 0x0)
	/home/user/go/src/github.com/go-shiori/shiori/internal/cmd/root.go:110 +0x74
github.com/go-shiori/shiori/internal/cmd.preRunRootHandler(0x2768b40, 0xb716b8, 0x0, 0x0)
	/home/user/go/src/github.com/go-shiori/shiori/internal/cmd/root.go:63 +0x174
github.com/spf13/cobra.(*Command).execute(0x2768b40, 0xb716b8, 0x0, 0x0, 0x2768b40, 0xb716b8)
	/home/user/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:810 +0x17c
github.com/spf13/cobra.(*Command).ExecuteC(0x2768000, 0x0, 0x0, 0x46324)
	/home/user/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x230
github.com/spf13/cobra.(*Command).Execute(...)
	/home/user/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
main.main()
	/home/user/go/src/github.com/go-shiori/shiori/main.go:19 +0x18
@deanishe
Copy link
Contributor

deanishe commented Aug 6, 2020

You can't cross-compile Shiori, I'm afraid. cgo doesn't support cross-compilation, and SQLite requires cgo.

I'd happily accept a PR that puts SQLite support behind a build tag, so Shiori can be cross-compiled (without SQLite support), but it's not something I consider a high priority myself.

@deanishe deanishe added the resolution:wontfix This will not be worked on label Aug 6, 2020
@atsai1220
Copy link

atsai1220 commented Feb 12, 2021

This image worked for me on my rpi4. malitov/rpi-shiori

docker run -d  --rm --name shiori -p 8081:8080 -v $(pwd):/srv/shiori malitov/rpi-shiori

pi@raspberrypi:~/shiori $ docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED              STATUS                PORTS                                            NAMES
a1c593682354   malitov/rpi-shiori                   "/usr/local/bin/shio…"   About a minute ago   Up About a minute     0.0.0.0:8081->8080/tcp                           shiori

I'd love to make a PR for this but I'm not sure how to go about modifying the Dockerfile to support different platforms. From my research it sounds like usingdocker buildx feature.

Reference: https://github.com/malitov/rpi-shiori

Looks like this PR will integrate armv7 build: #278

@sunrisepi
Copy link

I figured out another way to successfully compile the shiori Docker image on Raspberry Pi 4B (ARM, 32bit).

# build stage
FROM nathanosman/alpine-golang-armhf AS builder
RUN apk add --no-cache build-base
WORKDIR /src
COPY . .
RUN go build

# server image
FROM nathanosman/alpine-golang-armhf
COPY --from=builder /src/shiori /usr/local/bin/
ENV SHIORI_DIR /srv/shiori/
EXPOSE 8080
CMD ["/usr/local/bin/shiori", "serve"]

  • In the same directory with the Dockerfile and git code that was cloned, run the command docker build -t shiori .
  • Within about 20 minutes, the locally built docker image will be ready to use as shiori

Then you can just follow the steps in the wiki to use the docker image: https://github.com/go-shiori/shiori/wiki/Usage#running-docker-container

  • For reference, here is my docker-compose.yml code for running shiori. Then I run docker-compose up -d to create the container. After that, just go to port 4141 on the host you're running this from, login to shiori per the above wiki usage steps and enjoy!

    shiori:
    image: shiori
    container_name: shiori
    ports:
    - 4141:8080
    volumes:
    - /home/pi/mydockerapps/shiori/data:/srv/shiori
    restart: unless-stopped

I used a similar process to get wallabag to compile for Raspberry Pi 4B. References I followed, in case anyone else would like to build their own wallabag docker image:

Have fun! :)

@tricoos
Copy link

tricoos commented Oct 12, 2021

@sunrisepi Thanks, works perfectly!

@stale
Copy link

stale bot commented Feb 10, 2022

This issue has been automatically marked as stale because it has not had any activity for quite some time.
It will be closed if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the tag:stale label Feb 10, 2022
@fmartingr fmartingr added component:builds type:enhancement New feature or request and removed resolution:wontfix This will not be worked on tag:stale labels Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants