容器Dockerfile
FROM php:8.1-fpm-alpine3.16
RUN echo https://mirrors.ustc.edu.cn/alpine/v3.16/main > /etc/apk/repositories && \
echo https://mirrors.ustc.edu.cn/alpine/v3.16/community >> /etc/apk/repositories
# latest certs
RUN apk add ca-certificates --no-cache && update-ca-certificates
ENV TZ="Asia/Shanghai"
RUN apk add --update tzdata --no-cache && \
cp /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo $TZ > /etc/timezone && apk del tzdata
RUN apk update && apk upgrade
RUN apk add m4 autoconf make gcc g++ linux-headers wget zlib-dev git libxml2 libxml2-dev oniguruma oniguruma-dev && \
apk add bash strace su-exec
RUN apk add --update curl curl-dev libzip-dev openssl
RUN apk add libpng libpng-dev libjpeg-turbo-dev libwebp-dev libxpm-dev gd vim freetype freetype-dev && \
apk add libsodium musl libsodium-dev
RUN docker-php-ext-install opcache zip bcmath pdo_mysql mysqli mbstring xml soap curl gd
# install composer
RUN wget https://mirrors.aliyun.com/composer/composer.phar && mv composer.phar /usr/local/bin/composer && \
chmod +x /usr/local/bin/composer && \
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
RUN docker-php-ext-enable sodium
RUN docker-php-ext-install pcntl sockets xlswriter redis
COPY php.ini /usr/local/etc/php/php.ini
COPY php-fpm.conf /usr/local/etc/php-fpm.conf
COPY php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf
RUN sed -i "s/;clear_env = no/clear_env = no/p" /usr/local/etc/php-fpm.d/www.conf &&\
sed -i "s/daemonize = yes/daemonize = no/p" /usr/local/etc/php-fpm.conf &&\
sed -i 's/listen = 127.0.0.1:9000/listen = [::]:9000/p' /usr/local/etc/php-fpm.d/www.conf &&\
sed -i '/listen.allowed_clients = 127.0.0.1/d' /usr/local/etc/php-fpm.d/www.conf &&\
sed -i 's/error_log = \/var\/log\/php-fpm\/error.log/error_log = \/www\/logs\/php-fpm\/error.log/p' /usr/local/etc/php-fpm.conf
COPY docker-entrypoint.sh /usr/local/bin/
EXPOSE 9000
RUN ["chmod", "+x", "/usr/local/bin/docker-entrypoint.sh"]
CMD ["/bin/sh", "/usr/local/bin/docker-entrypoint.sh"]
容器启动脚本
docker-entrypoint.sh
#!/bin/bash
echo "info: starting php-fpm.."
php-fpm -c /usr/local/etc/php/php.ini -y /usr/local/etc/php-fpm.conf
标签:fpm,etc,构建,usr,&&,PHP8,Docker,php,local
From: https://www.cnblogs.com/nilyang/p/16825571.html