Create Dockerfile
Browse files- Dockerfile +60 -0
Dockerfile
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
33 |
+
WORKDIR /app
|
34 |
+
EXPOSE 4000
|
35 |
+
# 环境变量设置
|
36 |
+
ENV NODE_ENV=production
|
37 |
+
ENV HOST="0.0.0.0"
|
38 |
+
ENV SERVER_ORIGIN_URL=""
|
39 |
+
ENV MAX_REQUEST_PER_MINUTE=60
|
40 |
+
ENV AUTH_CODE=""
|
41 |
+
ENV DATABASE_URL=""
|
42 |
+
ENV CRON_EXPRESSION=""
|
43 |
+
RUN chmod +x ./docker-bootstrap.sh
|
44 |
+
CMD ["./docker-bootstrap.sh"]
|
45 |
+
|
46 |
+
# 定义最终使用的app阶段
|
47 |
+
FROM base AS app
|
48 |
+
COPY --from=build /app /app
|
49 |
+
WORKDIR /app
|
50 |
+
EXPOSE 4000
|
51 |
+
# 环境变量设置
|
52 |
+
ENV NODE_ENV=production
|
53 |
+
ENV HOST="0.0.0.0"
|
54 |
+
ENV SERVER_ORIGIN_URL=""
|
55 |
+
ENV MAX_REQUEST_PER_MINUTE=60
|
56 |
+
ENV AUTH_CODE=""
|
57 |
+
ENV DATABASE_URL=""
|
58 |
+
ENV CRON_EXPRESSION="0 8 * * *"
|
59 |
+
RUN chmod +x ./docker-bootstrap.sh
|
60 |
+
CMD ["./docker-bootstrap.sh"]
|