Docker Installation
3 minute read
The easiest way to install and run OpenDataBio is using Docker and the docker configuration files provided, which contain all the needed configurations to run ODB. Uses nginx and mysql, and supervisor for queues
Docker files
laraverl-app/
----docker/*
----./env.docker
----docker-compose.yml
----Dockerfile
----Makefile
These are adapted from this link, where you find a production setting as well.
Installation
Download OpenDataBio
Prerequisites
- Docker with Compose plugin (
docker composev2). - Linux/mac: user in the docker group or run with
sudo. - Windows: Docker Desktop (WSL2/Hyper-V enabled).
Quick start (Linux/mac, requires make)
cd opendatabio
make docker-init # copies .env.docker, builds/starts, installs composer, key, migrates, storage:link
make docker-init SEED=1 # same as above + optional seed for Locations/Taxons
- Assets are already committed in
public/build, so no npm step is needed inside Docker. - App: http://localhost:8081 (user
admin@example.org/password1) - phpMyAdmin: http://localhost:8082
Windows (PowerShell)
cd opendatabio
powershell -ExecutionPolicy Bypass -File scripts/docker-init.ps1
# optional seed
powershell -ExecutionPolicy Bypass -File scripts/docker-init.ps1 -Seed
Manual commands (if you do not have make installed)
cp .env.docker .env
docker compose up -d
docker compose exec -T -u www-data laravel composer install --optimize-autoloader
docker compose exec -T -u www-data laravel php artisan key:generate --force
docker compose exec -T -u www-data laravel php artisan migrate --force
docker compose exec -T -u www-data laravel php artisan storage:link
Optional seed without make:
docker compose exec -T -u www-data laravel php getseeds
docker exec -i odb_mysql mysql -uroot -psecret odbdocker < storage/Location*.sql
docker exec -i odb_mysql mysql -uroot -psecret odbdocker < storage/Taxon*.sql
rm storage/Location*.sql storage/Taxon*.sql
Data persistence
The docker images may be deleted without loosing any data. The mysql tables are stored in a volume. You may change to a local path bind.
docker volume list
Using
The Makefile file contains the following commands to interact with the docker containers and odb.
Commands to build and create the app
make docker-init- copy.env.docker(if missing), build/start containers, install composer, key, migrate, storage:linkmake build- build containersmake key-generate- generate the app key and adds to .envmake composer-install- install php dependenciemake composer-update- update php dependenciesmake composer-dump-autoload- execute composer dump-autoload within containermake migrate- create or update the databasemake drop-migrate- delete and recreate the databasemake seed-odb- seed the database with locations and taxons
Commands to access the docker containers
make start- start all containersmake stop- stop all containersmake restart- restart all containersmake ssh- enter the main laravel app containermake ssh-mysql- enter the mysql container, so you may the log to the database usingmysql -uUSER -pPWDmake mysql- enter the docker mysql consolemake ssh-nginx- enter the nginx containermake ssh-supervisord- enter the supervisord container
Maintenance commands
make optimize- clean caches and log filesmake info- show app infomake logs- show laravel logsmake logs-mysql- show mysql logsmake logs-nginx- show nginx logsmake logs-supervisord- show supervisor logs
Deleting & rebuilding
If you have issues and changed the docker files, you may need to rebuild:
#delete all images without loosing data
make stop #first stop all
docker system prune -a #and accepts Yes
make build
make start
Updating an existing Docker installation
Before updating, back up your database and storage/app/public/media.
- Update source code to the target version:
cd opendatabio
git fetch --tags
git checkout <target-tag-or-branch>
- Rebuild and restart containers:
make stop
make build
make start
- Update PHP dependencies and run database migrations:
make composer-install
make migrate
- Refresh Laravel caches and restart queue workers:
make optimize
docker compose exec -T -u www-data laravel php artisan queue:restart
If the new version introduces changes in .env, add the new keys before restarting workers in production.