Deploy a RESTful API using Laravel and Docker
José Fernando Cordova May 13
- API Laravel Boilerplate 5.5
- Apache 2
You can manage a RestFull API in the fastest, simplest and funniest way! and with open source code dependencies.
However you can contribute for a better performance, the goal is to focus on the code avoiding the configurations and having docker installed.
Running the tests
You have a Travis Pipeline to apply Continous Integration, and other technology to test this environment.
You can modify the runtests.sh from the scripts folder
Insert jobs, instructions, builds in this pipeline
Clone this respository and run the following commands based on your orchestrator;
cd docker-laravel-api-dev/ # Creating mount folder mkdir .docker/local-mysql-datadir docker stack deploy -c docker-compose.yml docker-laravel-api-dev # wait for it and follow the docker instructions!...
Clone this respository and run the following commands:
cd docker-laravel-api-dev/ docker-compose -f docker-compose.yml up --build -d # wait for it to build and follow the docker instructions!...
With Play with Docker and following the docker instructions, it is easy to deploy and test this environment!
Execute Laravel Pre-requisites
In the root directory:
# container lists docker ps # next, execute an interactive bash shell on the php container. docker container exec -t -i [dockerlaravelapidev_php_1 or container Id] bash
Run the following commands based on your orchestrator:
Compose and Swarm Mode
composer install && cp .env.example .env && php artisan key:generate && php artisan migrate chmod 755 -R storage # forward to the port 80, go to localhost and enjoy!...
Play With Docker (PWD)
composer install && php artisan migrate # forward to the port 80, go to localhost and enjoy!...
- How to fix Error: laravel.log could not be opened?
In the root directory or inside the container php: chmod -R 775 storage
- 7 - Owner can write
- 7 - Group can write
5 - Others cannot write!
API Boilerplate Reference
- *José Fernando Cordova * - Initial work - jfernancordova
This project is licensed under the MIT License - see the LICENSE.md file for details
- Hat tip to anyone who's code was used