Skip to content

Latest commit

 

History

History
239 lines (161 loc) · 6.32 KB

README.md

File metadata and controls

239 lines (161 loc) · 6.32 KB

Oscar Car Rental Build Status GitHub version

Docker running Nginx, PHP-FPM, Composer, MySQL and PHPMyAdmin.

Overview

  1. Install prerequisites

    Before installing project make sure the following prerequisites have been met.

  2. Clone the project

    We’ll download the code from its repository on GitHub.

  3. Run the application

    By this point we’ll have all the project pieces in place.

  4. Use Docker Commands

    When running, you can use docker commands for doing recurrent operations.

  5. Test Application


Install prerequisites

To run the docker commands without using sudo you must add the docker group to your-user:

sudo usermod -aG docker your-user

For now, this project has been mainly created for Unix (Linux/MacOS). Perhaps it could work on Windows.

All requisites should be available for your distribution. The most important are :

Check if docker-compose is already installed by entering the following command :

which docker-compose

Check Docker Compose compatibility :

On Ubuntu and Debian these are available in the meta-package build-essential. On other distributions, you may need to install the GNU C++ compiler separately.

sudo apt install build-essential

Images to use

You should be careful when installing third party web servers such as MySQL or Nginx.

This project use the following ports :

Server Port
MySQL 8989
PHPMyAdmin 8080
Nginx 8000

Clone the project

To install Git, download it and install following the instructions :

git clone https://github.com/sahedbs23/oscar-car-rental.git

Go to the project directory :

cd oscar-car-rental

Project tree

.
├── Makefile
├── README.md
├── data
│   └── db
│       ├── dumps
│       └── mysql
├── doc
├── docker-compose.yml
├── etc
│   ├── nginx
│   │   ├── default.conf
│   │   └── default.template.conf
│   ├── php
│   │   └── php.ini
│   └── ssl
└── web
    ├── app
    │   ├── composer.json.dist
    │   ├── phpunit.xml.dist
    │   ├── src
    │   │   └── App.php
    │   └── test
    │       └── bootstrap.php
    └── public
        └── index.php
  1. Start the application :

    docker-compose up -d

    Please wait this might take a several minutes...

    docker-compose logs -f # Follow log output
  2. Open your favorite browser :

  3. Stop and clear services

    docker-compose down -v

Use Docker commands

Installing package with composer

docker run --rm -v $(pwd)/web/app:/app composer require symfony/yaml

Updating PHP dependencies with composer

docker run --rm -v $(pwd)/web/app:/app composer update

Testing PHP application with PHPUnit

docker-compose exec -T php ./app/vendor/bin/phpunit --colors=always --configuration ./app

Analyzing source code with PHP Mess Detector

docker-compose exec -T php ./app/vendor/bin/phpmd ./app/src text cleancode,codesize,controversial,design,naming,unusedcode

Checking installed PHP extensions

docker-compose exec php php -m

Handling database

MySQL shell access

docker exec -it mysql bash

and

mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD"

Creating a backup of all databases

mkdir -p data/db/dumps
source .env && docker exec $(docker-compose ps -q mysqldb) mysqldump --all-databases -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" > "data/db/dumps/db.sql"

Restoring a backup of all databases

source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/db.sql"

Creating a backup of single database

Notice: Replace "YOUR_DB_NAME" by your custom name.

source .env && docker exec $(docker-compose ps -q mysqldb) mysqldump -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" --databases YOUR_DB_NAME > "data/db/dumps/YOUR_DB_NAME_dump.sql"

Restoring a backup of single database

source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/YOUR_DB_NAME_dump.sql"

Run the application

The Application exposed a few API endpoints

Notice: Import postman collection from api-doc/postman_collection.json

Notice: Import postman environment from api-doc/postman_environment.json

Notice: A car license is Unique at the Database level. You can import the content from the file just once.