Docker deploy static site

Posted on 2023-12-28 09:35:16
Author: 可乐小田子
FROM alpine:edge

WORKDIR /app

RUN apk add --no-cache
yarn
nginx

# 复制项目代码到容器中
COPY . /app

# 配置Yarn注册表并安装依赖项
RUN yarn config set registry "https://registry.npm.taobao.org" &&
yarn install &&
yarn cache clean

# 设置环境变量
ENV NODE_ENV=production

# 压缩生成的静态资源
RUN yarn build

# 复制Nginx配置文件
COPY nginx.conf /etc/nginx/nginx.conf

# 暴露容器内Nginx服务的端口
EXPOSE 8000

# 容器启动命令,启动Nginx并以守护进程方式运行
CMD ["nginx", "-g", "daemon off;"]


当前评论 (0) 登录后评论

暂无评论