windzmf commited on
Commit
50a5418
·
verified ·
1 Parent(s): f059870

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +61 -0
Dockerfile ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用Node.js的Alpine Linux版本作为基础镜像
2
+ FROM node:20-alpine AS base
3
+ ENV PNPM_HOME="/pnpm"
4
+ ENV PATH="$PNPM_HOME:$PATH"
5
+
6
+ # 全局安装pnpm
7
+ RUN npm i -g pnpm
8
+
9
+ # 创建一个新的构建阶段,克隆GitHub仓库
10
+ FROM base AS clone
11
+ WORKDIR /usr/src/app
12
+ RUN apk add --no-cache git
13
+ RUN git clone https://github.com/cooderl/wewe-rss.git .
14
+
15
+ # 构建应用
16
+ FROM base AS build
17
+ COPY --from=clone /usr/src/app /usr/src/app
18
+ WORKDIR /usr/src/app
19
+
20
+ # 使用pnpm安装依赖,构建应用
21
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
22
+ RUN pnpm run -r build
23
+
24
+ # 部署命令调整为使用克隆的代码
25
+ RUN pnpm deploy --filter=server --prod /app
26
+ RUN pnpm deploy --filter=server --prod /app-sqlite
27
+
28
+ # 生成Prisma客户端
29
+ RUN cd /app && pnpm exec prisma generate
30
+ RUN cd /app-sqlite && rm -rf ./prisma && mv prisma-sqlite prisma && pnpm exec prisma generate
31
+
32
+ # 定义最终使用的app-sqlite阶段
33
+ FROM base AS app-sqlite
34
+ COPY --from=build /app-sqlite /app
35
+ WORKDIR /app
36
+ EXPOSE 4000
37
+ # 环境变量设置
38
+ ENV NODE_ENV=production
39
+ ENV HOST="0.0.0.0"
40
+ ENV SERVER_ORIGIN_URL=""
41
+ ENV MAX_REQUEST_PER_MINUTE=60
42
+ ENV AUTH_CODE=""
43
+ ENV DATABASE_URL="file:../data/wewe-rss.db"
44
+ ENV DATABASE_TYPE="sqlite"
45
+ RUN chmod +x ./docker-bootstrap.sh
46
+ CMD ["./docker-bootstrap.sh"]
47
+
48
+ # 定义最终使用的app阶段
49
+ FROM base AS app
50
+ COPY --from=build /app /app
51
+ WORKDIR /app
52
+ EXPOSE 4000
53
+ # 环境变量设置
54
+ ENV NODE_ENV=production
55
+ ENV HOST="0.0.0.0"
56
+ ENV SERVER_ORIGIN_URL=""
57
+ ENV MAX_REQUEST_PER_MINUTE=60
58
+ ENV AUTH_CODE=""
59
+ ENV DATABASE_URL=""
60
+ RUN chmod +x ./docker-bootstrap.sh
61
+ CMD ["./docker-bootstrap.sh"]