Another way to setup Laravel expecting that you have git and composer installed on your machine. Presented in configuration file examples for fastest reading/setup.
Source code viewer
# Replace branch with the latest release. git clone -b 'v5.8.16' --single-branch --depth 1 https://github.com/laravel/laravel.git cd laravel rm -Rf .git composer install cp .env.example .env # Create configuration files for docker, example content of the files is given below. touch docker-compose.yml touch app.dockerfile touch web.dockerfile touch vhost.conf # The containers are build and ran. When you need to change config files then you need to run build, separately. docker-compose upProgramming Language: Bash
docker-compose.yml
Source code viewer
version: '2' services: app: build: context: ./ dockerfile: app.dockerfile working_dir: /var/www volumes: - ./:/var/www environment: - "DB_PORT=3306" - "DB_HOST=database" web: build: context: ./ dockerfile: web.dockerfile working_dir: /var/www volumes_from: - app ports: - 8080:80 database: image: mysql:5.6 volumes: - dbdata:/var/lib/mysql environment: - "MYSQL_DATABASE=homestead" - "MYSQL_USER=homestead" - "MYSQL_PASSWORD=secret" - "MYSQL_ROOT_PASSWORD=secret" ports: - "33061:3306" volumes: dbdata:Programming Language: YAML
app.dockerfile
Source code viewer
FROM php:7.3.5-fpm RUN apt-get update && apt-get install -y libmcrypt-dev \ mysql-client libmagickwand-dev --no-install-recommends \ && pecl install imagick mcrypt-1.0.2 \ && docker-php-ext-enable imagick mcrypt \ && docker-php-ext-install pdo_mysqlProgramming Language: Text
web.dockerfile
Source code viewer
FROM nginx:1.15.12 ADD vhost.conf /etc/nginx/conf.d/default.confProgramming Language: Text
vhost.conf
Source code viewer
server { listen 80; root /var/www/public; location / { } fastcgi_pass app:9000; include fastcgi_params; } }Programming Language: nginx
Source code viewer
find storage/ -type f -print0 | xargs -0 sudo chmod 666 find storage/ -type d -print0 | xargs -0 sudo chmod 777 find bootstrap/cache -type f -print0 | xargs -0 sudo chmod 666 find bootstrap/cache -type d -print0 | xargs -0 sudo chmod 777Programming Language: Bash
Source code viewer
docker exec laravel_app_1 php artisan key:generate docker exec laravel_app_1 php artisan optimizeProgramming Language: Bash
Configure your IDE accordingly.