jetlan commited on
Commit
c093977
·
verified ·
1 Parent(s): b439873

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -16
Dockerfile CHANGED
@@ -1,25 +1,24 @@
1
- # 使用官方 Nginx 镜像
2
- FROM nginx:latest
3
 
4
- # 维护者信息
5
- LABEL maintainer="your-email@example.com"
6
 
7
- # 设置工作目录
8
- WORKDIR /usr/share/nginx/html
9
 
10
- # 删除默认的 nginx 配置
11
- RUN rm /etc/nginx/nginx.conf /etc/nginx/conf.d/default.conf
12
 
13
- # 复制自定义 nginx 配置
14
- COPY nginx.conf /etc/nginx/nginx.conf
15
- COPY conf.d/ /etc/nginx/conf.d/
16
 
17
- # 复制静态文件到工作目录
18
- COPY ./html /usr/share/nginx/html
 
19
 
20
- # 暴露端口
21
  EXPOSE 10080
22
- EXPOSE 10443
23
 
24
- # 启动 Nginx
25
  CMD ["nginx", "-g", "daemon off;"]
 
1
+ # 使用官方nginx镜像作为基础
2
+ FROM nginx:alpine
3
 
4
+ # 设置维护者信息
5
+ LABEL maintainer="dev@example.com"
6
 
7
+ # 删除默认的nginx欢迎页面
8
+ RUN rm -rf /usr/share/nginx/html/*
9
 
10
+ # 修改nginx配置以监听端口10080
11
+ RUN sed -i 's/listen\(.*\)80;/listen 10080;/g' /etc/nginx/conf.d/default.conf
12
 
13
+ # 创建自定义的测试静态页面
14
+ COPY index.html /usr/share/nginx/html/
 
15
 
16
+ # 健康检查
17
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
18
+ CMD wget --no-verbose --tries=1 --spider http://localhost:10080/ || exit 1
19
 
20
+ # 暴露端口10080
21
  EXPOSE 10080
 
22
 
23
+ # 启动nginx(前台运行)
24
  CMD ["nginx", "-g", "daemon off;"]