:rocket: An example of Laravel app that runs in a docker container with RoadRunner
:rocket: An example of Laravel app that runs in a docker container with RoadRunner
This repository contains an example of Laravel (PHP Framework) application that runs in a docker container with RoadRunner (high-performance PHP application server) as a web server.
docker and docker-compose (make is optional, but strongly recommended)Dockerfile for local application development and running on productionopcache and jit compiler for the performance of your applicationphp-fpm + nginx and easy to deployMakefile allows to perform familiar operations easy and fastIf you want to integrate Docker + RoadRunner into an existing application, take a look at pull requests with the special label in the current repository - you can repeat these steps.
Another way is repository cloning, forking or usage this repository as a template for your application.
Don't forget to remove
TestJob,TestController, and routes, that are declared for this controller in theroutes/web.phpfile - it is used for internal application working tests.
Let's dive deeper and watch how to start application development, based on this template. First, we need to get the sources:
$ git clone https://github.com/tarampampam/laravel-roadrunner-in-docker.git
$ cd ./laravel-roadrunner-in-dockerAfter that - build image with our application and install composer dependencies:
…Make full application initialization:
$ make init
...
INFO Preparing database.
Creating migration table ..................................... 15ms DONE
INFO Running migrations.
2014_10_12_000000_create_users_table ......................... 27ms DONE
2014_10_12_100000_create_password_resets_table ............... 21ms DONE
2019_08_19_000000_create_failed_jobs_table ................... 17ms DONE
2019_12_14_000001_create_personal_access_tokens_table ........ 30ms DONE
INFO Seeding database.
...Start the application:
$ make up
...
Navigate your browser to ⇒ http://127.0.0.1:8080 or https://127.0.0.1:8443Voila! You can open (or ) in your browser and source code in your favorite IDE.
For watching all supported
makecommands executemakewithout parameters inside the project directory:$ make Available commands: help Show this help install Install all app dependencies shell Start shell into app container init Make full application initialization ...
Execute in your terminal:
$ make shellIn this shell, you can use composer, php, and any other tools, which are installed into a docker image.
$ docker-compose logs -fAll messages from all containers output will be listed here.
As it was told above - execute make shell and after that composer require %needed/package%.
make command?Append into Makefile something like:
your-command: ## Your command help
/bin/your/app -goes -hereTab character in front of your command is mandatory!
Read more about makefiles here.
This repo was created for Linux users. It maps /etc/passwd in docker-compose.yml to set the current host user for the Docker containers.
MacOS doesn't use /etc/passwd unless it's operating in single-user mode. Instead, it uses a system called Open Directory.
If you do make shell; whoami and get user errors, then you can fix by running ./scripts/fix_mac_user.sh. This script will create a mac_passwd file that plays nice with /etc/passwd used by docker-compose.yml under the volumes mapping section.
#!/bin/sh
// File: ./scripts/fix_mac_user.sh
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd $SCRIPT_DIR/../
echo "$USER:x:$(id -u):$(id -g):ns,,,:$HOME:/bin/bash" > mac_passwd
sed -i.backup 's~/etc/passwd:/etc/passwd:ro~./mac_passwd:/etc/passwd:ro~' docker-compose.ymlIf you find any package errors, please, make an issue in current repository.
This project is open-sourced software licensed under the MIT license.
No open issues yet, or sync has not completed.