dockerfile commit.
This commit is contained in:
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# 构建阶段
|
||||||
|
FROM node:lts-slim AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 安装 pnpm 并验证
|
||||||
|
RUN npm install -g pnpm@latest --no-cache && \
|
||||||
|
pnpm --version
|
||||||
|
|
||||||
|
# 复制依赖文件
|
||||||
|
COPY package.json pnpm-lock.yaml* ./
|
||||||
|
|
||||||
|
# 安装依赖,允许缺少 pnpm-lock.yaml
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
# 复制源代码并构建
|
||||||
|
COPY . .
|
||||||
|
RUN pnpm docs:build
|
||||||
|
|
||||||
|
# 运行时阶段
|
||||||
|
FROM nginx:alpine-slim AS runtime
|
||||||
|
#修改目标路径
|
||||||
|
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY --from=build --chown=nginx:nginx /app/src/.vuepress/dist /usr/share/nginx/html
|
||||||
|
EXPOSE 80
|
||||||
31
nginx/nginx.conf
Normal file
31
nginx/nginx.conf
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_min_length 1000;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
|
||||||
|
error_page 404 /404.html;
|
||||||
|
location = /404.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/index.html =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user