commit 33fe2d66acdb7ce6bb8636c416bc6e8cc8c86d0e Author: Georg Krause Date: Fri Apr 9 18:56:43 2021 +0200 Initial commit diff --git a/.env b/.env new file mode 100644 index 0000000..9280ed1 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +MYSQL_ROOT_PASSWORD=example +MYSQL_DATABASE=example diff --git a/README.md b/README.md new file mode 100644 index 0000000..17ffb2f --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# Mysql dev env + +This is a simple mysql development environment. It provides MySQL and PHPMyAdmin as a minimal +docker-compose deployment. both MySQL and PHPMyAdmin are exposed to the host and can be reached from +other applications + +## Setup + +In order to use the setup, clone this repository. The configuration is done in `.env`. +If you want a specific database to be created on container initialization, set `MYSQL_DATABASE`. Its +highly recommended to set `MYSQL_ROOT_PASSWORD` to something slightly more secure than `example`, +even its just a local development environment, especially when operating in public networks. + +## Database initialisation + +Databases can be imported using PHPMyAdmin. Nevertheless it can be useful to automatically load +database dumps on container creation. In order to do this, place arbitrary initialisation scripts in +the subdirectory `initdb.d`. To be executed these files need to have one of the following +extensions: + +- `.sh` +- `.sql` +- `.sql.gz` + +## Start + +Simply run `docker-compose up` to start the services. Run `docker-compose up -d` to run them in +background. + +## Reset + +To delete the created containers and start again with the initialization, execute `docker-compose +rm` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..de6a8d7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.1' + +services: + + db: + image: mysql + restart: always + env_file: + - .env + volumes: + - ./initdb.d:/docker-entrypoint-initdb.d + ports: + - 3306:3306 + + phpmyadmin: + image: phpmyadmin + restart: always + ports: + - 8080:80 + environment: + PMA_HOST: db + diff --git a/initdb.d/.gitkeep b/initdb.d/.gitkeep new file mode 100644 index 0000000..e69de29