crazy-max / docker-flarum

Flarum Docker image
MIT License
197 stars 32 forks source link

Composer stuck on installing/updating flarum extensions #104

Open derandiunddasbo opened 8 months ago

derandiunddasbo commented 8 months ago

Support guidelines

I've found a bug and checked that ...

Description

When trying to add or update any flarum extension by docker compose exec flarum extension require <extension>, the command never finishes with 100% CPU usage until I hit Ctrl-C. I tried this several times and let it run for a couple of hours.

Expected behaviour

Composer successfully downloading flarum extensions.

Actual behaviour

top - 16:28:20 up 22:21,  2 users,  load average: 0.70, 2.06, 2.63 [IO: 0.33, 0.39, 0.39 CPU: 0.37, 1.68, 2.25]
Tasks: 567 total,   2 running, 565 sleeping,   0 stopped,   0 zombie
%Cpu(s): 31.7 us, 26.8 sy,  0.0 ni, 39.5 id,  2.0 wa,  0.0 hi,  0.0 si,  0.0 st
GiB Mem :    7.718 total,    0.275 free,    1.862 used,    5.581 buff/cache
GiB Swap:    2.000 total,    1.778 free,    0.222 used.    5.382 avail Mem

  PID USER      PR  NI    VIRT    RES  %CPU  %MEM     TIME+ S COMMAND
 6600 991       20   0  194.4m  37.3m 97.40 0.472   0:10.41 R php /usr/bin/composer require clarkwinkelmann/flarum-ext-formatted-banner
[...]

I narrowed the problem down to the composer being stuck on downloading packages.json:

# docker exec -it flarum_flarum bash
1a237ca5c757:/opt/flarum# composer -vvv require clarkwinkelmann/flarum-ext-formatted-banner
Running 2.6.6 (2023-12-08 18:32:26) with PHP 8.2.14 on Linux / 3.10.108
Reading ./composer.json (/opt/flarum/composer.json)
Loading config file ./composer.json (/opt/flarum/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/opt/flarum): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing command (/opt/flarum): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/opt/flarum): git log --pretty="%H" -n1 HEAD
Executing command (/opt/flarum): hg branch
Executing command (/opt/flarum): fossil branch list
Executing command (/opt/flarum): fossil tag list
Executing command (/opt/flarum): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json

Reading ./composer.lock (/opt/flarum/composer.lock)
Reading /opt/flarum/vendor/composer/installed.json
Downloading https://repo.packagist.org/packages.json
^C
1a237ca5c757:/opt/flarum#

With wget I'm able to download packages.json successfully:

1a237ca5c757:/opt/flarum# wget https://repo.packagist.org/packages.json
Connecting to repo.packagist.org (135.125.205.55:443)
saving to 'packages.json'
packages.json        100% |*************************************************************************************************************************|  2584  0:00:00 ETA
'packages.json' saved

But interestingly, curl also get's stuck with 100% cpu usage when trying to download from the same URL:

1a237ca5c757:/opt/flarum# curl -v https://repo.packagist.org/packages.json
^C

composer diagnose also get's stuck on Checking http connectivity to packagist::

1a237ca5c757:/opt/flarum# composer diagnose
Checking composer.json: WARNING
require.flarum/approval : unbound version constraints (*) should be avoided
require.flarum/bbcode : unbound version constraints (*) should be avoided
require.flarum/core : exact version constraints (v1.8.3) should be avoided if the package follows semantic versioning
require.flarum/emoji : unbound version constraints (*) should be avoided
require.flarum/flags : unbound version constraints (*) should be avoided
require.flarum/lang-english : unbound version constraints (*) should be avoided
require.flarum/likes : unbound version constraints (*) should be avoided
require.flarum/lock : unbound version constraints (*) should be avoided
require.flarum/markdown : unbound version constraints (*) should be avoided
require.flarum/mentions : unbound version constraints (*) should be avoided
require.flarum/nicknames : unbound version constraints (*) should be avoided
require.flarum/pusher : unbound version constraints (*) should be avoided
require.flarum/statistics : unbound version constraints (*) should be avoided
require.flarum/sticky : unbound version constraints (*) should be avoided
require.flarum/subscriptions : unbound version constraints (*) should be avoided
require.flarum/suspend : unbound version constraints (*) should be avoided
require.flarum/tags : unbound version constraints (*) should be avoided
Checking platform settings: OK
Checking git settings: No git process found
Checking http connectivity to packagist: ^C
1a237ca5c757:/opt/flarum#

Steps to reproduce

# docker-compose exec flarum extension require clarkwinkelmann/flarum-ext-formatted-banner
^C
#

Docker info

Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 18
  Running: 18
  Paused: 0
  Stopped: 0
 Images: 34
 Server Version: 20.10.23
 Storage Driver: btrfs
  Build Version: Btrfs v4.0
  Library Version: 101
 Logging Driver: db
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs db fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b23a389d8c181697302d163356e97dec04eb8d88
 runc version: 5af893d
 init version: ed96d00
 Security Options:
  apparmor
 Kernel Version: 3.10.108
 Operating System: DiskStation

 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.718GiB
 Name: DerHamster
 ID: ZOQ2:RQMR:RXFW:XHDU:EDHO:VDFH:OIAP:BSOL:X3E4:PZGG:XDAY:2GCU
 Docker Root Dir: /volume1/@docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No kernel memory TCP limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Docker Compose config

name: flarum

services:
  traefik:
    image: traefik:2.5
    container_name: flarum_traefik
    command:
      - "--global.checknewversion=false"
      - "--global.sendanonymoususage=false"
      - "--log=true"
      - "--log.level=INFO"
      - "--entrypoints.http=true"
      - "--entrypoints.http.address=:80"
      - "--entrypoints.http.http.redirections.entrypoint.to=https"
      - "--entrypoints.http.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.https=true"
      - "--entrypoints.https.address=:443"
      - "--certificatesresolvers.letsencrypt"
      - "--certificatesresolvers.letsencrypt.acme.storage=acme.json"
      - "--certificatesresolvers.letsencrypt.acme.email=xxx"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=http"
      - "--providers.docker"
      - "--providers.docker.watch=true"
      - "--providers.docker.exposedbydefault=false"
    ports:
#      - target: 80
#        published: 80
#        protocol: tcp
      - target: 443
        published: 6443
        protocol: tcp
    volumes:
      - "./acme.json:/acme.json"
      - "/var/run/docker.sock:/var/run/docker.sock"
    restart: always

  db:
    image: mariadb:10.5
    container_name: flarum_db
    command:
      - "mysqld"
      - "--character-set-server=utf8mb4"
      - "--collation-server=utf8mb4_unicode_ci"
    volumes:
      - "./db:/var/lib/mysql"
    environment:
      - "TZ=Europe/Berlin"
      - "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
      - "MYSQL_DATABASE=flarum"
      - "MYSQL_USER=flarum"
      - "MYSQL_PASSWORD=xxx"
    restart: always

  msmtpd:
    image: crazymax/msmtpd:latest
    container_name: flarum_msmtpd
    env_file:
      - "./msmtpd.env"
    environment:
      - "TZ=Europe/Berlin"
    restart: always

  flarum:
    image: crazymax/flarum:latest
    container_name: flarum_flarum
    ports:
      - target: 8000
        published: 8000
        protocol: tcp
    depends_on:
      - db
      - msmtpd
    volumes:
      - "./data:/data"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.flarum.entrypoints=https"
      - "traefik.http.routers.flarum.rule=Host(`xxx`)"
      - "traefik.http.routers.flarum.tls=true"
      - "traefik.http.routers.flarum.tls.certresolver=letsencrypt"
      - "traefik.http.routers.flarum.tls.domains[0].main=xxx"
      - "traefik.http.services.flarum.loadbalancer.server.port=8000"
    environment:
      - "TZ=Europe/Berlin"
      - "PUID=991"
      - "PGID=991"
      - "DB_HOST=db"
      - "DB_NAME=flarum"
      - "DB_USER=flarum"
      - "DB_PASSWORD=xxx"
    env_file:
      - "./flarum.env"
    restart: always

Logs

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-fix-logs.sh: executing...
[cont-init.d] 00-fix-logs.sh: exited 0.
[cont-init.d] 01-fix-uidgid.sh: executing...
Switching to PGID 991...
Switching to PUID 991...
[cont-init.d] 01-fix-uidgid.sh: exited 0.
[cont-init.d] 02-fix-perms.sh: executing...
Fixing perms...
[cont-init.d] 02-fix-perms.sh: exited 0.
[cont-init.d] 03-config.sh: executing...
Setting timezone to Europe/Berlin...
Setting PHP-FPM configuration...
Setting PHP INI configuration...
Setting OpCache configuration...
Setting Nginx configuration...
Initializing files and folders...
Fixing permissions in /data/assets...
Fixing permissions in /data/extensions...
Fixing permissions in /data/storage...
Fixing permissions in /opt/flarum/vendor...
Checking parameters...
Checking database connection...
Waiting 60s for database to be ready...
Database ready!
Creating Flarum config file...
Migrating Flarum...
Nothing to migrate.
Migrating extension: flarum-flags
Nothing to migrate.
Migrating extension: flarum-approval
Nothing to migrate.
Migrating extension: flarum-tags
Nothing to migrate.
Migrating extension: flarum-suspend
Nothing to migrate.
Migrating extension: flarum-subscriptions
Nothing to migrate.
Migrating extension: flarum-sticky
Nothing to migrate.
Migrating extension: flarum-nicknames
Nothing to migrate.
Migrating extension: flarum-mentions
Nothing to migrate.
Migrating extension: flarum-markdown
Nothing to migrate.
Migrating extension: flarum-lock
Nothing to migrate.
Migrating extension: flarum-likes
Nothing to migrate.
Migrating extension: flarum-emoji
Nothing to migrate.
DONE.
Clearing the cache...
[cont-init.d] 03-config.sh: exited 0.
[cont-init.d] 04-svc-main.sh: executing...
[cont-init.d] 04-svc-main.sh: exited 0.
[cont-init.d] ~-socklog: executing...
[cont-init.d] ~-socklog: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
2024/03/18 13:11:37 [notice] 526#526: using the "epoll" event method
2024/03/18 13:11:37 [notice] 526#526: nginx/1.24.0
2024/03/18 13:11:37 [notice] 526#526: OS: Linux 3.10.108
2024/03/18 13:11:37 [notice] 526#526: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/03/18 13:11:37 [notice] 526#526: start worker processes
2024/03/18 13:11:37 [notice] 526#526: start worker process 568
2024/03/18 13:11:37 [notice] 526#526: start worker process 569
[18-Mar-2024 13:11:38] NOTICE: fpm is running, pid 522
[18-Mar-2024 13:11:38] NOTICE: ready to handle connections

Additional info

flarum.env:

MEMORY_LIMIT=256M
UPLOAD_MAX_SIZE=16M
OPCACHE_MEM_SIZE=128
REAL_IP_FROM=0.0.0.0/32
REAL_IP_HEADER=X-Forwarded-For
LOG_IP_VAR=http_x_forwarded_for

FLARUM_DEBUG=true
FLARUM_BASE_URL=https://xxx:6443

msmtpd.env:

# https://github.com/crazy-max/docker-msmtpd
SMTP_HOST=mail.your-server.de
SMTP_PORT=587
SMTP_TLS=on
SMTP_STARTTLS=on
SMTP_TLS_CHECKCERT=on
SMTP_AUTH=on
SMTP_USER=xxx
SMTP_PASSWORD=xxx
SMTP_FROM=xxx
crazy-max commented 7 months ago

Can you try with latest release?

Server Version: 20.10.23

Also your Docker engine is EOL, you should consider updating to latest stable.

derandiunddasbo commented 6 months ago

I'm not running flarum as a docker container on a Synology NAS anymore, as I faced multiple other issues with this setup. Meanwhile I moved my flarum instance to a proxmox LXC container. Thus, I can't test the latest image, sorry.

There is a high chance, this problem is caused by the ancient kernel and/or docker version on Synology NAS devices. I don't know if it's worth the effort, making this docker image compatible with Synology devices. Thus, feel free to close this big as "Won't Fix".