NathanVaughn / webtrees-docker

Up-to-date Docker image for webtrees with all the bells and whistles.
https://hub.docker.com/r/nathanvaughn/webtrees
MIT License
64 stars 15 forks source link

database user and schema creation #121

Closed baloan closed 1 year ago

baloan commented 1 year ago

I can't seem to get the docker container to create the user and the database schema webtrees. I think it requires access to the root user and thus cannot work with the current setup. I am using an already existing mysql database instance on the host. I have resorted to creating a user and database schema manually, which works partially: all tables and keys are created but the docker container fails to create the initial adminuser (wt_user table is empty, can't login). Also it is unclear to me which charset and collation to use for the database schema. My docker-compose.yml (anonymized):

version: "3"
services:
  webtrees: 
    image: nathanvaughn/webtrees
    container_name: webtrees
    restart: unless-stopped
    environment:
      - BASE_URL=https://example.com
      - LANG=de
      - DB_TYPE=mysql
      - DB_HOST=localhost
      - DB_PORT=3306
      - DB_USER=webtrees
      - DB_NAME=webtrees
      - DB_PASS=webtrees_password
      - DB_PREFIX=wt_
      - WT_USER=john
      - WT_PASS=john_password
      - WT_NAME=John
      - WT_EMAIL=some@email.com
    volumes:
      - data:/var/www/webtrees/data/
      - media:/var/www/webtrees/media/
      - themes:/var/www/webtrees/modules_v4/
volumes:
  data:
  media:
  themes:
NathanVaughn commented 1 year ago

It doesn't require access to the root user. I run my setup with a dedicated webtrees user and a webtrees database on a shared database server like you describe. Yes, this user and database must already exist, if you're not using a SQL database in the same docker-compose stack (since those will automatically create a user and database based on environment variables).

Here are the collation and charset on mine which works. I assume these are the default values in MariaDB: image

Lastly, I recommend un-setting all of your environment variables and going through the setup wizard manually. Since this goes through things step by step, it can help troubleshoot connection issues.

baloan commented 1 year ago

I've set up an empty database with the charset and collation utf8mb4_unicode_ci. When I start the webtrees docker I get the following initial display: image

root@nuc0:~/webtrees# docker logs -f webtrees
[NV_INIT] PRETTY_URLS NOT found in environment variables, using default: None
[NV_INIT] SSL NOT found in environment variables, using default: None
[NV_INIT] HTTPS NOT found in environment variables, using default: None
[NV_INIT] SSL_REDIRECT NOT found in environment variables, using default: None
[NV_INIT] HTTPS_REDIRECT NOT found in environment variables, using default: None
[NV_INIT] SSL_CERT_FILE NOT found in environment variables, using default: /certs/webtrees.crt
[NV_INIT] SSL_CERT_KEY_FILE NOT found in environment variables, using default: /certs/webtrees.key
[NV_INIT] BASE_URL NOT found in environment variables, using default: None
[NV_INIT] LANG NOT found in environment variables, using default: en-US
[NV_INIT] DB_TYPE NOT found in environment variables, using default: mysql
[NV_INIT] DB_HOST NOT found in environment variables, using default: None
[NV_INIT] DB_PORT NOT found in environment variables, using default: 3306
[NV_INIT] MYSQL_USER NOT found in environment variables, using default: None
[NV_INIT] MARIADB_USER NOT found in environment variables, using default: None
[NV_INIT] POSTGRES_USER NOT found in environment variables, using default: None
[NV_INIT] DB_USER NOT found in environment variables, using default: webtrees
[NV_INIT] MYSQL_PASSWORD NOT found in environment variables, using default: None
[NV_INIT] MARIADB_PASSWORD NOT found in environment variables, using default: None
[NV_INIT] POSTGRES_PASSWORD NOT found in environment variables, using default: None
[NV_INIT] DB_PASS NOT found in environment variables, using default: None
[NV_INIT] MYSQL_DATABASE NOT found in environment variables, using default: None
[NV_INIT] MARIADB_DATABASE NOT found in environment variables, using default: None
[NV_INIT] POSTGRES_DB NOT found in environment variables, using default: None
[NV_INIT] DB_NAME NOT found in environment variables, using default: webtrees
[NV_INIT] DB_PREFIX NOT found in environment variables, using default: wt_
[NV_INIT] WT_USER NOT found in environment variables, using default: None
[NV_INIT] WT_NAME NOT found in environment variables, using default: None
[NV_INIT] WT_PASS NOT found in environment variables, using default: None
[NV_INIT] WT_EMAIL NOT found in environment variables, using default: None
[NV_INIT] DB_KEY NOT found in environment variables, using default: None
[NV_INIT] DB_CERT NOT found in environment variables, using default: None
[NV_INIT] DB_CA NOT found in environment variables, using default: None
[NV_INIT] DB_VERIFY NOT found in environment variables, using default: None
[NV_INIT] PHP_MEMORY_LIMIT NOT found in environment variables, using default: 1024M
[NV_INIT] PHP_MAX_EXECUTION_TIME NOT found in environment variables, using default: 90
[NV_INIT] PHP_POST_MAX_SIZE NOT found in environment variables, using default: 50M
[NV_INIT] PHP_UPLOAD_MAX_FILE_SIZE NOT found in environment variables, using default: 50M
[NV_INIT] Setting up folder permissions for uploads
[NV_INIT] Updating php.ini
[NV_INIT] Creating php.ini
[NV_INIT] Setting value for memory_limit in php.ini
[NV_INIT] Setting value for max_execution_time in php.ini
[NV_INIT] Setting value for post_max_size in php.ini
[NV_INIT] Setting value for upload_max_filesize in php.ini
[NV_INIT] Updating config file
[NV_INIT] Setting value for rewrite_urls in config
[NV_INIT] WARNING: Not all database variables are set
[NV_INIT] Configuring HTTPS
[NV_INIT] Removing HTTPS
[NV_INIT] Disabling site webtrees-redir
Site webtrees-redir already disabled
[NV_INIT] Disabling site webtrees-ssl
Site webtrees-ssl already disabled
[NV_INIT] Enabling site webtrees
Enabling site webtrees.
To activate the new configuration, you need to run:
  service apache2 reload
[NV_INIT] Setting up folder permissions for uploads
[NV_INIT] Starting Apache
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.23.0.6. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.23.0.6. Set the 'ServerName' directive globally to suppress this message
[Mon Feb 13 14:39:48.352517 2023] [mpm_prefork:notice] [pid 34] AH00163: Apache/2.4.54 (Debian) PHP/8.1.14 OpenSSL/1.1.1n configured -- resuming normal operations
[Mon Feb 13 14:39:48.352632 2023] [core:notice] [pid 34] AH00094: Command line: 'apache2 -D FOREGROUND'
webtrees:80 127.0.0.1 - - [13/Feb/2023:14:40:17 +0000] "GET / HTTP/1.1" 302 651 "-" "curl/7.74.0"
webtrees:80 172.23.0.5 - - [13/Feb/2023:14:40:43 +0000] "GET /index.php?route=%2Flogin&url= HTTP/1.1" 200 4286 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0"
webtrees:80 127.0.0.1 - - [13/Feb/2023:14:41:00 +0000] "GET / HTTP/1.1" 302 651 "-" "curl/7.74.0"
baloan commented 1 year ago

I am completey baffled why webtrees switches to German on my browser.

  1. site settings is en-US as defaulted during installation. image
  2. my browser is set to en-US as well. image image
baloan commented 1 year ago

In addition to recreating the database it is necessary to delete the config.ini.php file in the data directory. Worth a note that the environment variables are only used as long as there is no config.ini.php file. Works for me now. Issue may be closed.

NathanVaughn commented 1 year ago

If the config.ini.php file already exists, the init script tries to update it. If the file does not exist, then it tries to automate the setup wizard. Since that file already existed, and I assume your database schema already existed too, webtrees skipped straight to the login screen.

Glad you got it figured out.