Webtrees is a really cool PHP-based web-application to show your family tree. The data comes from a GEDCOM file which is a standard format for genealogy data. Webtrees expects to be installed on a Webserver and to be told where to find a database for its state.
In this project I use Docker Compose to build 3 Containers to run the application out of Docker leaving the underlying host unmodified.
You can use this set-up to quickly start up Webtrees and give it a try. Or you can run your production deployment from it.
I have a "primary" set-up running on my home machine which is not exposed to the Internet. I set up a secondary instance on the Oracle Cloud Always Free tier and periodically upload a fresh copy of my GEDCOM file there for Family to peruse.
Prerequisites: You need to have Docker set up and running and you need to install docker-compose which may not be bundled with Docker itself.
git clone git@github.com:richardeigenmann/Webtrees-Docker.git
cd Webtrees-Docker
docker network create Webtrees-Net
docker volume create Webtrees-Data
# STOP AND THINK: do you want default passwords on the db?
# if not, modify them in the file docker-compose.yml
# under 'environment' first!
docker-compose up -d --build
# If you get an error about the permissions log into the container and correct them
docker exec -it Webtrees_webserver bash
root@827bbf76cde7:/# chmod 777 /var/www/data
# Ctrl-D
Then open: http://localhost
The Database paramters are:
- Server name: Webtrees_mysql_db
- Port number: 3306
- Database user account: wt
- Database password: password
Database and table names:
- Database name: webtrees
- Table prefix: leave unchaged
Administrator account
- Your Name: Bob Smith
- Username: bob
- Password: password
- E-mail address: nobody@gmail.com
Now head over to: https://www.webtrees.net
In particular to: https://wiki.webtrees.net/en/Users_Guide
docker-compose down --rmi all --volumes --remove-orphans
# docker stop Webtrees_webserver
# docker stop Webtrees_php_fpm
# docker stop Webtrees_mysql_db
# docker rm Webtrees_webserver
# docker rm Webtrees_php_fpm
# docker rm Webtrees_mysql_db
# docker network rm Webtrees-Net
# docker volume rm Webtrees-Data
The genealogy data is kept in the MySql database container that was started. If you stop and restart this container the data remains. If you delete this container the data is gone.
To extract the genealogy data you captured in Webtrees, click on My page > Control panel > Family trees > Manage family trees > GEDCOM file Export > A file on your computer - continue. This will create a gedcom file that you can keep as a backup and can later import.
Media files that you upload are kept in the docker volume named Webrtrees-Data. This is mounted to the Webtrees_webserver and Webtrees_php_fpm container. These files will stay around for as long as the volume stays around. If you want to copy the images to a safe place use the docker cp
command:
docker cp Webtrees_webserver:/var/www/data/media .
The docker-compose.yml file declares the 3 containers that are used. The 3 containers will connect with each other over the Docker internal network Webtrees-Net.
The configuration data for the Webtrees app and the media files will reside on the Webtrees-Data volume.
This container is defined by the Dockerfile (of the same name) and inherits from nginx. It receives a customised vhost.conf which forwards requests for php scripts to the fcgi container.
The nginx.conf is modified to allow image uploads up to 40M as the default is unusable.
The container is then populated with the webtrees code.
The startup starts fcgiwrap and then nginx in non daemon mode.
The webserver will run on port 8180. Change that to whatever you like in the docker-compose.yml and vhost.conf file.
The php scripts are run from a separate container. This inherits from php:7-fpm. Fastcgi acts as glue between the nginx container and the fpm container communicating over port 9000 on a private Docker network.
The Dockerfile-php adds libpng, freetype, libjpeg, libxml2 and unzip to the container. It also installs mysqli, pdo, pdo_mysql and xml as well as gd.
Webtrees is intalled into both containers so that the web container has the static images and the php container has the scripts.
The database uses the mysql image from Dockerhub as-is.
The docker-compose.yml file lists the username and password that will be used when the server starts up. You are advised to change this to something secure.
The database is not visible to the host and tools like phpmysqladmin will not find it. Add a port mapping to the docker-compose.yml file if you want to connect to the db.
The below command lists all running containers.
docker ps
You can connect to a running container and use the shell to check things:
docker exec -it Webtrees_webserver bash
docker exec -it Webtrees_php_fpm bash
For instance the following command shows the contents of the webserver directory:
ls /var/www
The webserver logs are redirected to stdout and stderr of the container and can be viewed with
docker logs Webtrees_webserver
You can interact with the database
docker exec -it Webtrees_mysql_db bash
mysql -u root -p
The server needs to be on the Internet and port 80 and 443 need to be visible.
docker exec -it Webtrees_webserver bash
apt-get update && apt-get install --assume-yes certbot python3-certbot-nginx
certbot --nginx -d www.example.com
nginx -t && nginx -s reload
docker-compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d www.example.com \
&& docker restart Webtrees_webserver