This project generates a text file based on the contents of a MySQL-database, that is generated by a SQL-script.
The project consists of two parts:
- A Laravel cli app
- A MySQL database
These two parts are dockerized using Docker and Docker Compose. When running the app using docker-compose, it launches a mysql-container that autoruns the sql-script located in the 'sqldump'-directory. It then launches the app-container, which waits for the MySQL-container to be ready to accept connections. When the database is ready, the main script is launched as a Laravel command. The command queries the database for all the users (200 at a time) and appends each of them as a line in a CSV-file generated in the 'output'-directory. If all goes well, it deletes the user from the database.
- /.env - Contains environment variables that are injected to docker-compose.yml
- /docker-compose.yml - Contains all the configuration for docker-compose
- /sqldump - All sql dumps located here will be run by the MySQL-container on startup
- /output/user_export.csv - The resulting csv-file will be located here
- /app - The directory containing the Laravel-app
- /app/Dockerfile - From this file, the Docker image of the Laravel app is generated
Project is created with:
- Docker version 19.03.8
- docker-compose version 1.25.5
- php:7.4-cli-alpine (Docker base image)
- mysql:8 (Docker base image)
- Laravel v7.18.0
To run this project, do the following:
$ git clone https://github.com/wogelius/cego-assignment.git
$ cd cego-assignment
$ docker-compose run app
$ docker-compose down
The project can be tested by doing the following:
$ git clone https://github.com/wogelius/cego-assignment.git
$ cd cego-assignment/app
$ composer install
$ php vendor/phpunit/phpunit/phpunit