From 45c0f0f0b56cc8a18cb61498f94b34a02a56655a Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 14:07:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=B9=E5=99=A8=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 12 ++++++++++++ dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 docker-compose.yml create mode 100644 dockerfile diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..150dc42 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' + +services: + php: + build: + context: . + dockerfile: Dockerfile + volumes: + - .:/var/www/html # 将当前目录挂载到容器 + command: php think run # 启动 PHP 内置服务器 + ports: + - "8000:8000" # 映射容器端口到主机端口 diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..693b248 --- /dev/null +++ b/dockerfile @@ -0,0 +1,22 @@ +# 使用 PHP 8.1 镜像 +FROM php:8.1-cli + +# 安装 OPcache 扩展 +RUN apt-get update && apt-get install -y libzip-dev \ + && docker-php-ext-install opcache \ + && docker-php-ext-install pdo pdo_mysql + +# 拷贝项目文件到容器 +COPY . /var/www/html/ + +# 设置工作目录 +WORKDIR /var/www/html/ + +# 安装 Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# 安装项目依赖 +RUN composer install --no-interaction + +# 配置 OPcache +COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini