mriedmann / humhub-docker

Alpine-based PHP-FPM and NGINX HumHub docker-container
MIT License
95 stars 79 forks source link

Running on ARMv7 - No MySQL, run with postgres db? #145

Closed breakingflower closed 3 years ago

breakingflower commented 3 years ago

I want to build from your repository and run on ARMv7.

Useful Information

pi@naspi:~/rpi4_server $ cat /proc/device-tree/model
Raspberry Pi 4 Model B Rev 1.1
pi@naspi:~/rpi4_server $ uname -a 
Linux naspi 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l GNU/Linux
pi@naspi:~/rpi4_server $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
pi@naspi:~/rpi4_server $ docker --version
Docker version 19.03.13, build 4484c46
pi@naspi:~/rpi4_server $ docker-compose --version
docker-compose version 1.27.4, build unknown

Build steps

Only the docker for amd64 is available, so we have to build locally.

Building from docker-compose

Local build fails if done from compose file, using the default compose file.

version: "3.8"
services:
  humhub:
    image: fremmen/humhub:armv7
    build: https://github.com/mriedmann/humhub-docker.git
    ...
docker-compose build humhub

Building locally

git clone https://github.com/mriedmann/humhub-docker
cd humhub-docker
docker build . --network host -t fremmen/humhub:armv7

The option --network host was added due to a npm install error - getaddrinfo EAI_AGAIN showing up without it and following this issue. The build succeeds.

Running

Humhub requires a database, but there is no MySQL docker for armv7. I tried the following setup:

version: "3.8"
services:
  humhub:
    image: fremmen/humhub:armv7
    ## Docker-compose build humhub does not work due to 
    #     npm install error - getaddrinfo EAI_AGAIN
    # build locally by
    # git clone https://github.com/mriedmann/humhub-docker.git && cd humhub-docker
    # docker build . --network host -t fremmen/humhub:armv7
    build: https://github.com/mriedmann/humhub-docker.git
    links:
      - "humhubdb:db"
    ports:
      - "${HUMHUB_PORT}:80"
    volumes:
      - ${APPDATA_ROOT}/humhub/config:/var/www/localhost/htdocs/protected/config
      - ${APPDATA_ROOT}/humhub/uploads:/var/www/localhost/htdocs/uploads
      - ${APPDATA_ROOT}/humhub/modules:/var/www/localhost/htdocs/protected/modules
    environment:
      - HUMHUB_DB_HOST=humhubdb
      - HUMHUB_DB_NAME=humhub
      - HUMHUB_DB_USER=humhub
      - HUMHUB_DB_PASSWORD=${HUMHUB_DB_ROOT_PW}
    depends_on:
      - humhubdb
  humhubdb:
    image: postgres:alpine
    restart: unless-stopped
    volumes:
      - humhub_db:/var/lib/postgresql/data
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TIMEZONE}
      - POSTGRES_DB=humhub
      - POSTGRES_USER=humhub
      - POSTGRES_PASSWORD=${HUMHUB_DB_ROOT_PW}
    ports:
      - "${HUMHUB_DB_PORT}:5432"
volumes:
  humhub_db:

But I get the following message

humhub       | Waiting for database connection...

Is postgres not supported? What can I do to get it working with armv7?

mriedmann commented 3 years ago

Hi!

As far as I know, MySQL/MariaDB is the only Database-System that is supported by HumHub. You can try to use one of the community-built MariaDB images (e.g https://hub.docker.com/r/jsurf/rpi-mariadb). If you are using something like Raspian or another OS (maybe your system is no RPi) it might be possible to install MariaDB or MySQL directly on the System and just use it.

Just to avoid confusion: HumHub was written for MySQL and is therefore compatible with MariaDB because it is "just" the OpenSource variant of MySQL. PostgreSQL is a completely different DB System and not fully compatible with MySQL. HumHub is using a framework that should make it possible to connect it to non-MySQL DBs but that is not tested and will cause some problems. Also is our container currently very focused on MySQL. If you really need Postgres Support we can add it but maybe using MariaDB is easier for you.

Cheers

ArchBlood commented 3 years ago

Hi!

As far as I know, MySQL/MariaDB is the only Database-System that is supported by HumHub. You can try to use one of the community-built MariaDB images (e.g https://hub.docker.com/r/jsurf/rpi-mariadb). If you are using something like Raspian or another OS (maybe your system is no RPi) it might be possible to install MariaDB or MySQL directly on the System and just use it.

Just to avoid confusion: HumHub was written for MySQL and is therefore compatible with MariaDB because it is "just" the OpenSource variant of MySQL. PostgreSQL is a completely different DB System and not fully compatible with MySQL. HumHub is using a framework that should make it possible to connect it to non-MySQL DBs but that is not tested and will cause some problems. Also is our container currently very focused on MySQL. If you really need Postgres Support we can add it but maybe using MariaDB is easier for you.

Cheers

MySQL mariadb/innodb are the only databases that are supported from my understanding so using PostgreSQL or any other would be almost impossible without editing the core to support it

breakingflower commented 3 years ago

For future people stumbling upon this thread, I've managed to solve it using the tip from @mriedmann by using a user created mariadb image. In the end my compose file looks like this:

  humhub:
    container_name: humhub
    image: fremmen/humhub:armv7
    ## Docker-compose build humhub does not work due to 
    #     npm install error - getaddrinfo EAI_AGAIN
    # build locally by
    # git clone https://github.com/mriedmann/humhub-docker.git && cd humhub-docker
    # docker build . --network host -t fremmen/humhub:armv7 
    # the above succeeds.
    build: https://github.com/mriedmann/humhub-docker.git
    links:
      - "humhubdb:db"
    ports:
      - "${HUMHUB_PORT}:80"
    volumes:
      - ${APPDATA_ROOT}/humhub/config:/var/www/localhost/htdocs/protected/config
      - ${APPDATA_ROOT}/humhub/uploads:/var/www/localhost/htdocs/uploads
      - ${APPDATA_ROOT}/humhub/modules:/var/www/localhost/htdocs/protected/modules
    environment:
      - HUMHUB_DB_HOST=humhubdb
      - HUMHUB_DB_NAME=humhub
      - HUMHUB_DB_USER=humhub
      - HUMHUB_DB_PASSWORD=${HUMHUB_DB_USER_PW}
    depends_on:
      - humhubdb
  humhubdb:
    container_name: humhubdb
    image: tobi312/rpi-mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=${HUMHUB_DB_ROOT_PW}
      - MYSQL_DATABASE=humhub
      - MYSQL_USER=humhub
      - MYSQL_PASSWORD=${HUMHUB_DB_USER_PW}
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "--silent"]
      interval: 30s
      timeout: 10s
      retries: 3
    volumes:
      - humhub_db:/var/lib/mysql
    ports:
      - "${HUMHUB_DB_PORT}:5432"