-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c8eaba
commit 0155212
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 使用官方 Node.js 镜像作为基础镜像 | ||
FROM node:18-alpine AS build | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 复制 pnpm 配置文件和 lock 文件 | ||
COPY pnpm-lock.yaml ./ | ||
COPY .npmrc ./ | ||
|
||
# 安装 pnpm | ||
RUN npm install -g pnpm | ||
|
||
# 复制项目文件 | ||
COPY package.json pnpm-workspace.yaml ./ | ||
COPY packages/game ./packages/game | ||
|
||
# 安装依赖 | ||
RUN pnpm install | ||
|
||
# 切换到前端项目目录并构建项目 | ||
WORKDIR /app/packages/game | ||
RUN pnpm run build | ||
|
||
# 使用官方 Nginx 镜像作为基础镜像 | ||
FROM nginx:alpine | ||
|
||
# 复制构建后的文件到 Nginx 的 html 目录 | ||
COPY --from=build /app/packages/game/dist /usr/share/nginx/html | ||
|
||
# 复制 Nginx 配置文件 | ||
COPY packages/game/nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
# 暴露端口 | ||
EXPOSE 80 | ||
|
||
# 启动 Nginx | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
server { | ||
listen 80; # 监听端口 | ||
|
||
location / { | ||
root /var/www/html; # 项目路径 | ||
index index.html index.htm; # 默认首页 | ||
try_files $uri $uri/ /index.html; # 重定向 | ||
} | ||
|
||
# 配置反向代理 | ||
location /api { | ||
proxy_pass http://8.210.206.35:7788; # 代理地址 | ||
proxy_set_header Host $host; # 设置请求头 | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} |