souramoo / commentoplusplus

Commento with out of the box patches and updates to add useful features and fixes. Also with one-click deploy to Heroku so you can get up and running fast.
MIT License
389 stars 62 forks source link

`exec /commento/commento: exec format error` when setting up with docker on raspberry pi 3b+ #119

Closed sander1095 closed 2 years ago

sander1095 commented 2 years ago

Hello!

I am following this tutorial to set up commento++:

https://noted.lol/commento-a-self-hosted-comment-system-for-websites-that-just-works/

When I use that exact dockerfile (while changing the COMMENTO_ORIGIN``to my own) and runningdocker-compose up`, I get the following logs on my raspberry pi 3b+:.

db_1      |
db_1      | PostgreSQL Database directory appears to contain a database; Skipping initialization
server_1  | exec /commento/commento: exec format error
db_1      |
db_1      | 2022-08-19 16:12:41.758 UTC [1] LOG:  starting PostgreSQL 12.5 on arm-unknown-linux-musleabihf, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 32-bit
db_1      | 2022-08-19 16:12:41.758 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1      | 2022-08-19 16:12:41.758 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db_1      | 2022-08-19 16:12:41.780 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1      | 2022-08-19 16:12:41.871 UTC [21] LOG:  database system was shut down at 2022-08-19 16:11:44 UTC
db_1      | 2022-08-19 16:12:41.893 UTC [1] LOG:  database system is ready to accept connections
commento_server_1 exited with code 1

FYI: My dockerfile looks like this:

version: '3'

services:
  server:
    image: caroga/commentoplusplus:v1.8.6
    ports:
      - 8080:8080
    environment:
#   I tried both, neither work!
      COMMENTO_ORIGIN: https://commento.mydomain.com
#    COMMENTO_ORIGIN: http://127.0.0.1:8080
      COMMENTO_PORT: 8080
      COMMENTO_POSTGRES: postgres://postgres:postgres@db:5432/commento?sslmode=disable
#    Note: These are copied from the blog post. I want to disable them, but even commenting them out doesn't make the server start.
      COMMENTO_SMTP_HOST: smtp.mailgun.org
      COMMENTO_SMTP_PORT: 587
      COMMENTO_SMTP_USERNAME: mailgun.smtp.user
      COMMENTO_SMTP_PASSWORD: mailgun-password
      COMMENTO_SMTP_FROM_ADDRESS: noreply@noted.lol
    depends_on:
      - db
  db:
    image: postgres:12.5-alpine
    environment:
      POSTGRES_DB: commento
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    volumes:
      - commento_data_volume:/var/lib/postgresql/data

volumes:
  commento_data_volume:

I don't really know where to go from here. According to the reactions on that blog post, everything should work fine :) I must be doing something wrong in a dumb way!


Bonus question:

I plan to run this behind a Caddy reverse proxy, but I don't think that's the issue here because the server doesn't even start up.

In any case, if I run it behind a reverse proxy (So caddy will forward traffic from commento.mydomain.com:80 -> 127.0.0.1:8096, should I set my COMMENTO_ORIGIN to 127.0.0.1:8080 or to commento.mydomain.com? I tried both, neither make the server start up.

souramoo commented 2 years ago

Actually, exec format error suggests that the correct executable format is not present but the RPi3B+ is an arm64 device.

Please could you double check you are using the correct arm64 image rather than the amd64 image?

sander1095 commented 2 years ago

Wow! Thanks for the ultra fast reply!

I only see amd64 on the docker hub: https://hub.docker.com/r/caroga/commentoplusplus/tags

How would I be able to install an arm64 image?

sander1095 commented 2 years ago

AFAIK I have the amd64 image:

image image

Trying to pull an arm64 image doesn't seem to do anything:

docker pull --platform linux/arm64 caroga/commentoplusplus

Using default tag: latest
latest: Pulling from caroga/commentoplusplus
627fad6f28f7: Already exists
82f99835a7e6: Pull complete
1cbb7ea2d6d1: Pull complete
36bb4bd6c3d0: Pull complete
528f23f9d205: Pull complete
b0b14070fc27: Pull complete
ba8fb94bda71: Pull complete
1359ca970a94: Pull complete
29dcfe1c479b: Pull complete
51ea55f8e2b6: Pull complete
338541b19cc1: Pull complete
Digest: sha256:1f4aeda0aad6e3e5dc56a81814469b0496c83984a0fa609f51399c971b36c703
Status: Downloaded newer image for caroga/commentoplusplus:latest
WARNING: image with reference caroga/commentoplusplus was found but does not match the specified platform: wanted linux/arm64, actual: linux/amd64
docker.io/caroga/commentoplusplus:latest
sander1095 commented 2 years ago

So, there is currently no way to run this on a pi because of missing arm64 support, right?

I have no go or arm64 knowledge, but I suppose I can take a look, perhaps this weekend. I'd love to use this on my Pi!

@souramoo Could you point me in the right direction for detecting where this issue originates?

I looked through the PR that you mentioned, but I can't see any changes in arm64 support. I do see a link to this github actions page with failed builds, but I do not know the relevance to arm64 and I can't see the logs anymore because of retention settings, making this a difficult issue to debug.

sander1095 commented 2 years ago

I'm looking into the base images the Dockerfile uses, but I don't see anything that wouldn't support arm64.

I feel like I am kind of out of my depth here, apologies! :)

@Wonderfall (sorry for the random tag), you commented here that support should be removed for arm because of issues. Could I ask you to help me out here? Especially since you created the PR for a better dockerfile; you might have more knowledge about this than me ♥

Thanks!

sander1095 commented 2 years ago

If I clone the repo and run docker-compose up, it actually DOES start up.

My first hunch is that arm is now actually supported! I will test a bit more now

souramoo commented 2 years ago

Thanks for looking into this! Yes you're right, I have updated the docker build process - please try pulling the latest one as there should be an arm64 image now on dockerhub!

sander1095 commented 2 years ago

Hey @souramoo , I think this isnt't working yet.

If I use this docker compose file:

version: '3.7'

services:
  commento:
    image: caroga/commentoplusplus
    environment:
      COMMENTO_ORIGIN: 'https://commento.MYDOMAIN.COMl'
      COMMENTO_PORT: '8080'
      COMMENTO_POSTGRES: 'postgres://postgres:postgres@db:5432/commento?sslmode=disable'
      #COMMENTO_FORBID_NEW_OWNERS: 'true' # enable this after your own registration
      COMMENTO_GZIP_STATIC: 'true'
    depends_on:
      - db
    ports:
      - 8080:8080

  db:
    image: postgres:12.5-alpine
    environment:
      POSTGRES_DB: 'commento'
      POSTGRES_USER: 'username'
      POSTGRES_PASSWORD: 'password'
    volumes:
      - /mnt/usb_hdd/commento:/var/lib/postgresql/data

running docker compose up gives me this error:

[+] Running 0/2
 ⠇ db Pulling                                                                                                                                                                                              
 ⠇ commento Pulling                                                                                                                                                                                        
no matching manifest for linux/arm/v7 in the manifest list entries

Could you still look into this?

Also, should another github release be required for this? I am pulling the latest images. I still see version 1.8.7 on github and docker hub; I thought an architecture change would require 1.8.8 or 1.9.0` or something? :)

souramoo commented 2 years ago

I will look into this! I think it's looking for armv7 (32 bit arm) rather than arm64

The code for commento is the same so I kept the version number constant, just a further architecture we are compiling for, but if I need to make further changes to the codebase to get it to work I will bump the version number :)

Wonderfall commented 2 years ago

Yes, linux/arm/v7 is currently not supported by Commento++ Docker images. Maybe just adding it in the GitHub Actions workflow can work, granted all the dependencies (images and packages) work fine with that.

Wonderfall commented 2 years ago

Actually, it shouldn't be the problem as the Raspberry Pi 3 is arm64. Can you try the image from ghcr.io instead (i.e. ghcr.io/souramoo/commentoplusplus:v1.8.7)?

sander1095 commented 2 years ago

Hi @Wonderfall !

I tried changing my image to that, but I get the following error.

$ docker-compose up
Creating network "commento_db_network" with the default driver
Pulling db (postgres:)...
latest: Pulling from library/postgres
1dd75a3a9c89: Pull complete
8f6cdce8dc6d: Pull complete
30477bb0f5ba: Pull complete
875cf022be7c: Pull complete
d2944002bb18: Pull complete
8348182e37a7: Pull complete
8d93bdcf1638: Pull complete
21ba15ecf279: Pull complete
6b2b0bb279bf: Pull complete
92222cc08bc4: Pull complete
afa74fbada95: Pull complete
8ad1e7d66231: Pull complete
a39d6d1b5b4e: Pull complete
Digest: sha256:f8816ada742348e1adfcec5c2a180b675bf6e4a294e0feb68bd70179451e1242
Status: Downloaded newer image for postgres:latest
Pulling commento (ghcr.io/souramoo/commentoplusplus:v1.8.7)...
v1.8.7: Pulling from souramoo/commentoplusplus
ERROR: no matching manifest for linux/arm/v7 in the manifest list entries

For full disclosure, here is my dockerfile:

version: '3'

services:
  commento:
    image: ghcr.io/souramoo/commentoplusplus:v1.8.7
    ports:
      - 8080:8080
    environment:
      COMMENTO_ORIGIN: https://commento.stenbrinke.nl
      COMMENTO_PORT: 8080
      COMMENTO_POSTGRES: postgres://postgres:postgres@db:5432/commento?sslmode=disable
    depends_on:
      - db
    networks:
      - db_network
  db:
    image: postgres
    environment:
      POSTGRES_DB: commento
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    networks:
      - db_network
    volumes:
      - postgres_data_volume:/var/lib/postgresql/data

networks:
  db_network:

volumes:
  postgres_data_volume:

I run raspbian lite :) Running uname -a (thanks to this site) tells me that I have Linux raspberrypi 5.15.32-v7+ #1538 SMP Thu Mar 31 19:38:48 BST 2022 armv7l GNU/Linux

Edit: I just remember, there is a 64 bit version of raspbian , but I don't have that installed :) So I think I have the 32 bit ARM version

@Wonderfall You say that linux/armv7 is not supported.. But as I said before, If I run this repo myself and run docker-compose up on the provided docker-compose.yml (after tweaking some settings), everything works swimmingly. So the only conclusion I have is that it IS supported on linux/armv7?

Wonderfall commented 2 years ago

You can see here the supported platforms: https://github.com/souramoo/commentoplusplus/blob/master/.github/workflows/docker-image.yml#L53

I suggest you try installing an arm64 OS since your hardware should be capable.

sander1095 commented 2 years ago

I'd like to suggest to add arm7 32-bit to the supported list :)

64-bit on raspberry pi 3b+ can work, but there are still some things that might cause issues. And personally I don't want to reinstall my entire system for this; that is probably understandable ;)

@souramoo and @Wonderfall What are your thoughts on this? I am currently setting up the system, and it seems to work completely fine on my system.

It's of course a small thing, but it'd be nice to just pull the official image instead of having to build it myself :).

I have already created a PR for this ;) https://github.com/souramoo/commentoplusplus/pull/121

Wonderfall commented 2 years ago

It should work just fine if we add support for linux/arm/7, indeed.

souramoo commented 2 years ago

Arm v7 compiled successfully - should now be present on all docker repos!