Database - Fi0x/LanguageGenerator GitHub Wiki

Overview

The web-version of this tool requires a database to run. You can either use your own (when you set it up correctly), or follow these instructions, to start a database with docker.

Database with docker

Docker will be used, to host the database. If you already have a database, that you want to use, you can follow these instructions to set it up correctly.

Install docker

  1. Use sudo apt update and sudo apt upgrade to get your pi up-to-date.
  2. Use sudo apt install docker to install docker
  3. Add user to the docker-group with sudo usermod -a -G docker ${USER}
  4. Add docker to autostart with sudo systemctl enable docker

Start docker-container

The container will be used, to host a database for your web-server.

First startup

This only needs to be done, if you haven't created the docker-container before. If you have already followed these instructions before and want to start the docker-container again, go to the next step

  • To start a container with a mysql database for the first time, run docker run --name mysql --env MYSQL_DATABASE=languages --env MYSQL_PASSWORD=122 --env MYSQL_ROOT_PASSWORD=1234 --env MYSQL_USER=dummyUser --publish 3306:3306 --restart unless-stopped -v languages-volume:/var/lib/mysql mysql:latest
    • Container name (mysql): The name of the docker-container
    • Environment variables (Those should match the settings in your application.properties-file):
      • MYSQL_DATABASE (languages): The name of the database
      • MYSQL_PASSWORD (123): The password for the user, that is used to log into the database
      • MYSQL_ROOT_PASSWORD (1234): The password for the root user, that has access to the database
      • MYSQL_USER (dummyUser): The username, that should be used to log into the database
    • Run options:
      • --publish (3306:3306): The port, on which the database is reachable for the application. Should match the database-port in the application.properties-file
      • -v (languages-volume:/var/lib/mysql): The volume, that will be used to store the database, even when the container is not running
    • Image-id (mysql:latest): The docker-image that should be used for the container. Changing this part also requires an update to the application.properties-file

Second and consecutive startups

If you have started the docker-container before and just need to start it again because you stopped it or it shut down, you should use docker start instead of the run command

Custom database

If you already have a database running and want to use it for this tool, you only need to follow the instructions for the database-setup and configure the application.properties correctly.

Database Setup

When you use a new database for the first time, you need to add 2 tables manually, since they are not created by the application itself on startup. The tables can be added, by running src/main/resources/schema.sql.