Skip to content

Commit

Permalink
feat:增加docker文件、初次使用docker
Browse files Browse the repository at this point in the history
  • Loading branch information
pengmao committed Apr 19, 2024
1 parent 426f4c7 commit 8f0136d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.temp
cache
dist
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 使用 Node.js 官方提供的 Node 镜像作为基础镜像来构建项目
FROM node:14-alpine AS build

# 设置工作目录
WORKDIR /app

# 复制 package.json 和 package-lock.json 文件到工作目录
COPY package*.json ./

# 安装依赖
RUN npm install

# 复制所有文件到工作目录
COPY . .

# 构建项目
RUN npm run docs:build

# 使用 Nginx 官方提供的 Nginx 镜像作为基础镜像
FROM nginx:alpine

# 将构建后的项目文件复制到 Nginx 默认的静态文件目录
COPY --from=build /app/docs/.vitepress/dist /usr/share/nginx/html

# 暴露 Nginx 的默认端口
EXPOSE 80

# 启动 Nginx
CMD ["nginx", "-g", "daemon off;"]

0 comments on commit 8f0136d

Please sign in to comment.