|
# 使用官方的 Nginx 镜像作为基础 |
|
FROM nginx:stable-alpine |
|
|
|
# 删除 Nginx 默认的配置文件 |
|
# Alpine 基础镜像里默认的配置文件路径可能是 /etc/nginx/http.d/default.conf 或 /etc/nginx/conf.d/default.conf |
|
# 为了保险起见,可以都尝试删除,或者先确认路径 |
|
RUN rm -f /etc/nginx/conf.d/default.conf /etc/nginx/http.d/default.conf |
|
|
|
# 将我们自己写的 Nginx 配置文件复制到容器里 Nginx 读取配置的目录 |
|
COPY nginx.conf /etc/nginx/nginx.conf |
|
# 注意:这里我们直接覆盖主配置文件 nginx.conf,而不是放在 conf.d 目录 |
|
# 因为我们提供了完整的 http 和 events 块 |
|
|
|
# 暴露 8080 端口 (Hugging Face Space 会访问这个端口) |
|
# 注意:README.md 中 app_port 也需要是 8080 |
|
EXPOSE 8080 |
|
|
|
# 容器启动时运行 Nginx,使用前台模式 |
|
CMD ["nginx", "-g", "daemon off;"] |
|
|