forked from Ouonnki/OuonnkiTV
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (43 loc) · 1.38 KB
/
Dockerfile
File metadata and controls
57 lines (43 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 多阶段构建
# 第一阶段:构建应用
FROM node:20-alpine AS builder
# 构建参数
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
ARG VITE_PROXY_URL
ARG VITE_INITIAL_VIDEO_SOURCES
# 设置工作目录
WORKDIR /app
# 安装 pnpm
RUN npm install -g pnpm@9.15.4
# 复制 package.json 和 pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./
# 安装依赖
RUN pnpm install --frozen-lockfile
# 复制源代码
COPY . .
# 设置构建时环境变量
ENV VITE_PROXY_URL=${VITE_PROXY_URL}
ENV VITE_INITIAL_VIDEO_SOURCES=${VITE_INITIAL_VIDEO_SOURCES}
# 构建应用
RUN pnpm build
# 第二阶段:运行时环境
FROM nginx:alpine AS production
# 添加标签
LABEL org.opencontainers.image.title="OuonnkiTV"
LABEL org.opencontainers.image.description="OuonnkiTV Web Application"
LABEL org.opencontainers.image.version=${VERSION}
LABEL org.opencontainers.image.created=${BUILD_DATE}
LABEL org.opencontainers.image.revision=${VCS_REF}
LABEL org.opencontainers.image.source="https://github.com/Ouonnki/OuonnkiTV"
# 复制构建产物到 nginx 静态文件目录
COPY --from=builder /app/dist /usr/share/nginx/html
# 复制 nginx 配置文件
COPY nginx.conf /etc/nginx/nginx.conf
# 暴露端口
EXPOSE 80
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1# 启动 nginx
CMD ["nginx", "-g", "daemon off;"]