Dockerでの新規作成方法まとめの自分用メモ
PHP
docker run -p 4000:80 -v ${PWD}:/var/www/html -d php:apache
参考:https://gray-code.com/blog/php-on-docker/
mysqlもつける場合: https://and-engineer.com/articles/Ybx0hREAACEAgRY9
laravel sail
curl -s https://laravel.build/<YOUR_PROJECT_NAME> |bash
とか
curl -s "https://laravel.build/<YOUR_PROJECT_NAME>?PHP=81" |bash
参考: Amazon プロフェッショナルWebプログラミング Laravel〈最新Laravel 9対応〉
laravel docker
参考: https://www.engilaboo.com/laravel-nginx-docker/
参考の手順で、と言うかdocker/Dockerfile以外参考見ればいける
- docker/Dockerfile
FROM php:8.0-fpm
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN apt-get update && apt-get install -y \
git \
zlib1g-dev \
libzip-dev \
unzip \
&& docker-php-ext-install pdo_mysql zip
- docker-compose.yaml
version: "3.8"
services:
app:
build: ./docker
volumes:
- ./app:/var/www/app
nginx:
image: nginx
ports:
- 8083:80
volumes:
- ./app:/var/www/app
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- 3306:3306
- docker/nginx/default.conf
server {
listen 80;
root /var/www/app/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
作成して
appフォルダ作成して
docker compose up -d