[Docker] 画像変換に最適なセットを入れた、PHP8.1+Nginxのdocker-compose設定

ファイル構成

/ ├ docker-compose.yml ├ nginx │  ├ Dockerfile │ └ default.conf └ php └ Dockerfile

docker-compose.yml

version: '3' services: php: container_name : php build : ./php volumes: - ./php/php.ini:/etc/php.ini - ../../public:/var/www/html working_dir: /var/www/html nginx: container_name: nginx build : ./nginx ports: - 8888:80 volumes: - ./nginx/default.conf:/etc/nginx/conf.d/default.conf - ../../public:/var/www/html depends_on: - php

nginx/Dockerfile

FROM nginx:1.19.5-alpine

nginx/ default.conf

server { listen 80; server_name localhost; index index.php index.html; root /var/www/html; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass php:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }

php/Dockerfile

FROM php:8.1-fpm-alpine RUN apk update && \ apk add --update --no-cache \ libjpeg-turbo-dev \ libwebp-dev \ libpng-dev RUN docker-php-ext-configure gd --with-jpeg RUN docker-php-ext-install -j$(nproc) gd # Archive RUN apk update && apk add -u curl RUN apk update && apk add -u zip RUN apk update && apk add -u unzip RUN apk update && apk add -u vim RUN apk update && apk add -u libpng-dev RUN apk update && apk add -u iputils-ping RUN apk update && apk add -u bc RUN apk update && apk add -u unarj