Docker Installation
How to install OpenDataBio with Docker
4 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 configuration files provided for test or development only
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
- Make sure you have Docker and Docker-compose installed in your system;
##ubuntu
docker --version
sudo apt update
sudo apt install docker
sudo apt install docker-compose-plugin
- Check if your user is in the docker group created during docker installation;
getent group docker
# If not in the list, add it
# Add the docker group if it does not exist
sudo groupadd docker
# Add the currently logged-in user to the docker group
sudo gpasswd -a $USER docker
# Restart the Docker service
sudo service docker restart
- Download or clone the OpenDataBio in your machine;
- Make sure your user is the owner of the opendatabio folder created and contents, else change ownership and group recursively to your user
- Enter the opendatabio directory
- Create and adjust configuration environment file
.env
.
Important
#create the file
cp .env.docker .env
#edit this file to change database name, password, etc..
- To install locally for development just adjust the following variables in the
Dockerfile
, which are needed to map the files owners to a docker user;UID
the numeric user your are logged in and which is the owner of all files and directories in the opendatabio directory.GDI
the numeric group the user belongs, usually same as UID.
#current user
id -u #if UID=1000 do not need to adjust
#current user group
id -g #if GDI=1000 do not need to adjust
- File
Makefile
contains shortcuts to the docker-compose commands used to build the services configured in thedocker-compose.yml
and auxiliary files in thedocker
folder. - Build the docker containers using the shortcuts (read the Makefile to undersand the commands)
make build
- Start the implemented docker Services
make start
- See the containers and try log into the laravel container
docker ps
make ssh #to enter the container shell
make ssh-mysql #to enter the mysql container, where you may access the database shell using `mysql -uroot -p` or use the laravel user
- Generate the APP_KEY
make key-generate
- Install composer dependencies
make composer-install
- Migrate the database
make migrate
- Seed the Locations and Taxons tables with seed data:
make seed-odb
- If worked, then Opendatabio will be available in your browser http::/localhost:8081.
- Login with superuser
admin@example.org
and passwordpassword1
- The database will be available with phpmyadmin at http://localhost:8082/
- Additional configurations in these files are required for a production environment and deployment;
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 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 -pPWD
make 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