dakaca commited on
Commit
6c5522e
·
1 Parent(s): b7a051c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -27
Dockerfile CHANGED
@@ -1,33 +1,21 @@
1
- FROM nginx
 
2
 
3
- # 设置环境变量
4
- ENV MYSQL_HOST db
5
- ENV MYSQL_USER myapp
6
- ENV MYSQL_PASSWORD example
7
- ENV MYSQL_DATABASE myapp
8
 
9
- # 安装 PHP 和相关扩展
10
- RUN apt-get update && \
11
- apt-get install -y php-fpm php-mysql && \
12
- apt-get clean && \
13
- rm -rf /var/lib/apt/lists/*
14
 
15
- # 安装 MySQL 客户端
16
- RUN apt-get update && \
17
- apt-get install -y mysql-client && \
18
- apt-get clean && \
19
- rm -rf /var/lib/apt/lists/*
20
 
21
- # 将 PHP 配置文件复制到容器中
22
- COPY php-fpm.conf /etc/php/7.4/fpm/php-fpm.conf
23
- COPY www.conf /etc/php/7.4/fpm/pool.d/www.conf
24
 
25
- # 将 PHP 文件复制到容器中
26
- COPY index.php /usr/share/nginx/html
27
 
28
- # 设置文件权限
29
- RUN chown -R www-data:www-data /usr/share/nginx/html && \
30
- chmod -R 755 /usr/share/nginx/html
31
- EXPOSE 7860
32
- # 启动 PHP-FPM 服务
33
- CMD ["php-fpm7.4", "-F", "-R"]
 
1
+ # 使用官方的PHP镜像作为基础镜像
2
+ FROM php:7.4-apache
3
 
4
+ # 安装MySQL客户端和PHP扩展
5
+ RUN apt-get update && apt-get install -y \
6
+ default-mysql-client \
7
+ && docker-php-ext-install mysqli pdo_mysql
 
8
 
9
+ # 将Apache的默认站点配置文件替换为自定义的配置文件
10
+ COPY apache2.conf /etc/apache2/apache2.conf
11
+ COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
 
 
12
 
13
+ # 复制PHP应用程序到Apache的默认站点目录
14
+ COPY index.php /var/www/html/
 
 
 
15
 
16
+ # 暴露Apache的默认端口
17
+ EXPOSE 7860
 
18
 
19
+ # 启动Apache服务器
20
+ CMD ["apache2-foreground"]
21