wogelius / cego-assignment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cego assignment

Table of contents

General info

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.

Important directories and files

  • /.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

Technologies

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

Setup

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

Testing

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

About


Languages

Language:PHP 85.7%Language:TSQL 10.3%Language:HTML 3.1%Language:Dockerfile 0.8%