FROM php:8.2-fpm-bookworm RUN echo "deb http://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list \ && echo "deb http://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list \ && echo "deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list RUN apt-get update # 安装nginx RUN apt-get install -y nginx ADD --chmod=0755 https://delivery.ulthon.com/install-php-extensions /usr/local/bin/ # ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN install-php-extensions pdo_mysql RUN install-php-extensions gd RUN install-php-extensions fileinfo RUN install-php-extensions opcache RUN install-php-extensions redis RUN install-php-extensions event RUN install-php-extensions imagick RUN install-php-extensions zip RUN install-php-extensions pcntl # 清理默认 Nginx 配置 RUN rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default # 安装其他需要的依赖 # RUN apt-get install -y ffmpeg # RUN apt-get install -y libreoffice # RUN apt-get install -y redis-server # RUN apt-get install -y git # 设置工作目录 WORKDIR /var/www/html # 将当前目录下的文件拷贝到工作目录 COPY . /var/www/html # 内部安装compsoer并安装依赖,如果不需要可以注释掉 # RUN install-php-extensions @composer VOLUME /var/www/html/runtime VOLUME /var/www/html/public/storage VOLUME /var/www/html/public/build VOLUME /var/www/html/storage # 挂载主目录,也可以选择直接挂载主目录,可以把上面的几个指定的目录删掉 # VOLUME ["/var/www/html"] # 暴露 Nginx 端口 EXPOSE 80 RUN chmod +x /var/www/html/docker/run.sh # 启动 Nginx PHP 然后阻塞 ENTRYPOINT ["/var/www/html/docker/run.sh"] CMD ["server"]