solidnerd/docker-bookstack

build image on raspberrypi (arm64) fails

HJF9w opened this issue · 5 comments

HJF9w commented

Hey, so I used your repo to try and build the docker image on arm, but when I run it, it errors out and crashes.

What I did was clone the repo, and then do a docker build -t test:1 .
The image is created without any errors in the log.

But when I replace the image in the example docker-compose from solidnerd/bookstack:22.04.02 to test:1, and run docker-compose up I get this:

Creating bookstack_db_1 ... done                                                                                                                                                                                                           
Creating bookstack_app_1 ... done                                                                                                                                                                                                          
Attaching to bookstack_db_1, bookstack_app_1
db_1   | 2022-07-09 12:13:09+02:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1.el8 started.                                                                                                                           
db_1   | 2022-07-09 12:13:09+02:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'                                                                                                                                                
db_1   | 2022-07-09 12:13:10+02:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1.el8 started.                                                                                                                           
db_1   | 2022-07-09 12:13:10+02:00 [Note] [Entrypoint]: Initializing database files                                                                                                                                                        
db_1   | 2022-07-09T10:13:10.343947Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.                                     
db_1   | 2022-07-09T10:13:10.343986Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.29) initializing of server in progress as process 44                                                                                     
db_1   | 2022-07-09T10:13:10.370615Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.                                                                                                                                    
app_1  | wait-for-db: waiting for db:3306                                                                                                                                                                                                  db_1   | 2022-07-09T10:13:14.363394Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.                                                                                                                                      
db_1   | 2022-07-09T10:13:19.767253Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.                                                   
db_1   | 2022-07-09 12:13:31+02:00 [Note] [Entrypoint]: Database files initialized                                                                                                                                                         
db_1   | 2022-07-09 12:13:31+02:00 [Note] [Entrypoint]: Starting temporary server                                                                                                                                                          
db_1   | 2022-07-09T10:13:31.887171Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.                                     
db_1   | 2022-07-09T10:13:31.887230Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29) starting as process 93                                                                                                               
db_1   | 2022-07-09T10:13:31.946218Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.                                                                                                                                    
db_1   | 2022-07-09T10:13:32.741035Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.                                                                                                                                      
db_1   | 2022-07-09T10:13:33.473497Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.                                                                                                                                
db_1   | 2022-07-09T10:13:33.473604Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.                                                               
db_1   | 2022-07-09T10:13:33.547662Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock                                                                                                   
db_1   | 2022-07-09T10:13:33.548023Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server - GPL.                             
db_1   | 2022-07-09 12:13:33+02:00 [Note] [Entrypoint]: Temporary server started.                                                                                                                                                          
db_1   | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'                                                                                                                                                                      
db_1   | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.                                                                                                                                              
db_1   | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.                                                                                                                                              
bookstack_app_1 exited with code 124                                                                                                                                                                                                       
db_1   | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.                                                                                                                                                
db_1   | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.                                                                                                                                                 
db_1   | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.                                                                                                                                             
db_1   | 2022-07-09 12:14:00+02:00 [Note] [Entrypoint]: Creating database bookstack                                                                                                                                                        
db_1   | 2022-07-09 12:14:00+02:00 [Note] [Entrypoint]: Creating user bookstack
db_1   | 2022-07-09 12:14:01+02:00 [Note] [Entrypoint]: Giving user bookstack access to schema bookstack             
db_1   |                                                                                                                                                                                                                                   
db_1   | 2022-07-09 12:14:01+02:00 [Note] [Entrypoint]: Stopping temporary server                                                                                                                                                          
db_1   | 2022-07-09T10:14:01.270014Z 13 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.29).                                                                                            
db_1   | 2022-07-09T10:14:04.508536Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.29)  MySQL Community Server - GPL.                                                                                    
db_1   | 2022-07-09 12:14:05+02:00 [Note] [Entrypoint]: Temporary server stopped                                                                                                                                                           
db_1   |                                                                                                                                                                                                                                   
db_1   | 2022-07-09 12:14:05+02:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.                                                                                                                                       
db_1   |                                                                                                                                                                                                                                   
db_1   | 2022-07-09T10:14:05.965947Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.                                     
db_1   | 2022-07-09T10:14:05.966004Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29) starting as process 1                                                                                                                
db_1   | 2022-07-09T10:14:05.991332Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.                                                                                                                                    
db_1   | 2022-07-09T10:14:06.784394Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.                
db_1   | 2022-07-09T10:14:07.365924Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.          
db_1   | 2022-07-09T10:14:07.366031Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.                                                               
db_1   | 2022-07-09T10:14:07.438221Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock                                                                   db_1   | 2022-07-09T10:14:07.438541Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.                          
app_1  | Generating Key...                                                                                                                                                                                                                 
app_1  | wait-for-db: done                                                                                                                                                                                                                 
app_1  | base64:s57xXh8sAEyZv3VjsRybRuNG8sfN88LQBKVf4U/Ev8A=                                                                                                                                                                               
app_1  | Starting Migration...                                                                                                                                                                                                             
app_1  |                                                                                                                                                                                                                                   
app_1  |    Illuminate\Database\QueryException                                                                                                                                                                                             
app_1  |                                                                                                                                                                                                                                   
app_1  |   SQLSTATE[HY000] [1045] Access denied for user 'bookstack'@'172.25.0.3' (using password: YES) (SQL: select * from information_schema.tables where table_schema = bookstack and table_name = migrations and table_type = 'BASE TAB
LE')                                                                                                                 
app_1  |                                                                                                                                                                                                                                   
app_1  |   at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712                                                                                                                                                          
app_1  |     708▕         // If an exception occurs when attempting to run a query, we'll format the error                                                                                                                                 
app_1  |     709▕         // message to include the bindings with SQL, which will make this exception a                                                                                                                                    
app_1  |     710▕         // lot more helpful to the developer instead of just the database's errors.                                                                                                                                      
app_1  |     711▕         catch (Exception $e) {                                                                                                                                                                                           
app_1  |   ➜ 712▕             throw new QueryException(                                                                                                                                                                                    
app_1  |     713▕                 $query, $this->prepareBindings($bindings), $e                                                                                                                                                            
app_1  |     714▕             );                                                                                                                                                                                                           
app_1  |     715▕         }                                                                                                                                                                                                                
app_1  |     716▕     }                                                                                                                                                                                                                    
app_1  |                                                                                                                                                                                                                                   
app_1  |       +33 vendor frames                                                                                                                                                                                                           
app_1  |   34  artisan:37                                                                                                                                                                                                                  
app_1  |       Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))                                                                     bookstack_app_1 exited with code 1 

Because of the error that the access was denied I tested to connect to the db from my docker host, mysql -ubookstack -p -h 172.0.23.3 was successful, and I can see the bookstack db with SHOW DATABASES;

Any help would be appreciated!

HJF9w commented

doing the exact same on X86 yields a perfectly functioning image.

for completion, this is the docker-compose that i use:

version: "2"
services:
  db:
    image: 'mysql' 
    environment:
      - TZ=Europe/Berlin
      - MYSQL_ROOT_PASSWORD=lol
      - MYSQL_PASSWORD=lol
      - MYSQL_USER=bookstack
      - MYSQL_DATABASE=bookstack
    volumes:
      - '${basepath}/${COMPOSE_PROJECT_NAME}/mysql-data:/var/lib/mysql'
    restart: unless-stopped
    networks:
      default:

  app:
    image: 'test:5'
    environment:
    #set the APP_ to the URL of bookstack without without a trailing slash APP_URL=https://example.com
      - APP_URL=http://localhost
      - DB_HOST=db
      - DB_PASS=lol
      - DB_USER=bookstack
      - DB_DATABASE=bookstack
    volumes:
      - '${basepath}/${COMPOSE_PROJECT_NAME}/uploads:/var/www/bookstack/public/uploads'
      - '${basepath}/${COMPOSE_PROJECT_NAME}/storage-uploads:/var/www/bookstack/storage/uploads'
    restart: unless-stopped
    depends_on:
      - db
    networks:
      default:
      xe_internal:

networks:
  xe_internal:
    external: true
  default:
HJF9w commented

just caught that the DB_HOST variable did not contain the port, sadly DB_HOST=db:3306 does not change the result.

HJF9w commented

After reading in this issue: linuxserver/docker-bookstack#58 (comment)
I tried removing MYSQL_ROOT_PASSWORD=lol from the mysql service,
discovered that you then have to add the MYSQL_ALLOW_EMPTY_PASSWORD=1 env,
And then ran the compose file.
bookstack crashed relatively quickly:

╰─>$ docker-compose up                                                                                                                                                                                                                     
Creating volume "docker-bookstack_mysql-data" with default driver                                                                                                                                                                          
Creating volume "docker-bookstack_uploads" with default driver                                                                                                                                                                             
Creating volume "docker-bookstack_storage-uploads" with default driver                                                                                                                                                                     
Creating docker-bookstack_mysql_1 ... done                                                                                                                                                                                                 
Creating docker-bookstack_bookstack_1 ... done                                                                                                                                                                                             
Attaching to docker-bookstack_mysql_1, docker-bookstack_bookstack_1                                                                                                                                                                        
bookstack_1  | wait-for-db: waiting for mysql:3306                                                                                                                                                                                         
mysql_1      | 2022-07-09 18:37:23+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1.el8 started.                                                                                                                     
mysql_1      | 2022-07-09 18:37:23+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'                                                                                                                                          
mysql_1      | 2022-07-09 18:37:23+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1.el8 started.                                                                                                                     
mysql_1      | 2022-07-09 18:37:23+00:00 [Note] [Entrypoint]: Initializing database files                                                                                                                                                  
mysql_1      | 2022-07-09T18:37:24.002810Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.29) initializing of server in progress as process 42
mysql_1      | 2022-07-09T18:37:24.033020Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.                                                                                                                              
mysql_1      | 2022-07-09T18:37:35.787066Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.          
mysql_1      | 2022-07-09T18:37:57.820190Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.                                             
docker-bookstack_bookstack_1 exited with code 124                                           

So after the db had initialized, I head to stop and restart it all,
and now it seems to work.
I am currently not sure if that was actually what "fixed" my problem, but I am going to test that.

HJF9w commented

Yea, so when building on raspberrypi you seem to have to run mysql without root password, with the DB_HOST variable a port is only required if it's not the default one (3306).
Also to stop the container from exiting (most of the time with exited with code 124) you have to change the timeout in the docker-entrypoint.sh from 15 to 30:

echoerr "wait-for-db: waiting for ${DB_HOST_NAME}:${DB_PORT}"

timeout 30 bash <<EOT
while ! (echo > /dev/tcp/${DB_HOST_NAME}/${DB_PORT}) >/dev/null 2>&1;
    do sleep 1;

and the sleep time from 1 sec to 10:


if [ $RESULT -eq 0 ]; then
  # sleep another second for so that we don't get a "the database system is starting up" error
  sleep 10
  echoerr "wait-for-db: done"

I am pretty sure that this does not actually fix the bug, but only circumvents the problem.

I did write a PR that works with rpi (at least on my machine!!!!) aarch64