前端静态文件打包在nginx镜像中

 假如我的前端是用vue开发的,打包之后的静态文件放在dist文件夹中,我想把这些静态文件打包在nginx镜像中,该怎么写Dockerfile呢?直接上配置吧

# 使用官方 nginx 镜像作为基础镜像
FROM nginx:alpine

# 删除默认 nginx 的 index 文件
RUN rm -rf /usr/share/nginx/html/*

# 拷贝 dist 文件到 nginx 的 html 目录
COPY dist/ /usr/share/nginx/html/

# 自定义的 nginx 配置文件,如果需要的话
# COPY nginx.conf /etc/nginx/nginx.conf

# 暴露端口
EXPOSE 80

# 启动 nginx
CMD ["nginx", "-g", "daemon off;"]
posted @ 2025-06-27 10:11  羊脂玉净瓶  阅读(20)  评论(0)    收藏  举报