[GH-ISSUE #254] Panic while trying to run cross compiled binary on Raspberry PI #188

Closed
opened 2026-02-25 23:33:39 +03:00 by kerem · 5 comments
Owner

Originally created by @quaintdev on GitHub (Jun 7, 2020).
Original GitHub issue: https://github.com/go-shiori/shiori/issues/254

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
Originally created by @quaintdev on GitHub (Jun 7, 2020). Original GitHub issue: https://github.com/go-shiori/shiori/issues/254 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 ```
Author
Owner

@deanishe commented on GitHub (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.

<!-- gh-comment-id:670203877 --> @deanishe commented on GitHub (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.
Author
Owner

@atsai1220 commented on GitHub (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: https://github.com/go-shiori/shiori/pull/278

<!-- gh-comment-id:778020059 --> @atsai1220 commented on GitHub (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 using`docker buildx` feature. Reference: https://github.com/malitov/rpi-shiori Looks like this PR will integrate armv7 build: https://github.com/go-shiori/shiori/pull/278
Author
Owner

@sunrisepi commented on GitHub (Feb 21, 2021):

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! :)

<!-- gh-comment-id:782783715 --> @sunrisepi commented on GitHub (Feb 21, 2021): I figured out another way to successfully compile the shiori Docker image on Raspberry Pi 4B (ARM, 32bit). - Get this version of alpine from docker hub and pull it to your pi: **docker pull nathanosman/alpine-golang-armhf** (for reference, docker hub link: https://hub.docker.com/r/nathanosman/alpine-golang-armhf) - Clone the shiori github code to a directory on your pi: **git clone https://github.com/go-shiori/shiori.git** - cd to the directory containing the cloned gitcode, and update the Dockerfile as shown below (changes from original Dockerfile are in **bold**): \# 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: - https://github.com/wallabag/wallabag/issues/4872 - https://www.dahl-jacobsen.dk/tips/blog/2017-10-18-wallabag/ **Have fun!** :)
Author
Owner

@tricoos commented on GitHub (Oct 12, 2021):

@sunrisepi Thanks, works perfectly!

<!-- gh-comment-id:940798797 --> @tricoos commented on GitHub (Oct 12, 2021): @sunrisepi Thanks, works perfectly!
Author
Owner

@stale[bot] commented on GitHub (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.

<!-- gh-comment-id:1035560830 --> @stale[bot] commented on GitHub (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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shiori#188
No description provided.