Nginxのconfを作成する
server {
listen 80;
root /usr/share/nginx/laravel/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ ^/.+\.php(/|$) {
fastcgi_pass laravel-container:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
DockerでPHP-FPMを作成する
FROM php:7.3-fpm-alpine
RUN apk add libzip-dev
RUN docker-php-ext-configure zip --with-libzip
RUN docker-php-ext-install pdo_mysql zip
docker-composeを作成する
version: "3.7"
services:
laravel:
build: .
container_name: laravel-container
working_dir: /usr/share/nginx/laravel
networks:
- laravel-docker
volumes:
- ./laravel:/usr/share/nginx/laravel
nginx:
image: nginx:1.16-alpine
container_name: reverse-proxy
working_dir: /usr/share/nginx/laravel
networks:
- laravel-docker
ports:
- "8080:80"
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
- ./laravel:/usr/share/nginx/laravel
mysql:
image: mysql:8.0
container_name: mysql-server
networks:
- laravel-docker
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=homestead
- MYSQL_USER=homestead
- MYSQL_PASSWORD=secret
ports:
- 3306:3306
redis:
image: redis:5.0-alpine
container_name: redis-server
networks:
- laravel-docker
ports:
- 6379:6379
networks:
laravel-docker:
driver: bridge
詳細は下記(ハンズオン)