showme commited on
Commit
af262ca
·
verified ·
1 Parent(s): 6466583

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -35
Dockerfile CHANGED
@@ -5,62 +5,33 @@ FROM node:20-alpine AS base
5
  ENV PNPM_HOME="/pnpm"
6
  ENV PATH="$PNPM_HOME:$PATH"
7
 
8
- # 安装最新的 OpenSSL 和 git
9
  RUN apk update && apk add --no-cache \
10
  openssl \
11
  git \
12
  && rm -rf /var/cache/apk/*
13
 
14
- # 安装最新版本的 npm 和 pnpm
15
- RUN npm install -g npm@latest
16
  RUN npm install -g pnpm
17
 
18
  # 克隆 GitHub 仓库
19
  WORKDIR /usr/src/app
20
  RUN git clone https://github.com/ShowMeTheMoney2023/top.git .
21
 
22
- # 创建空的 node_modules 目录,避免权限错误
23
  RUN mkdir -p /usr/src/app/node_modules /usr/src/app/.pnpm
24
 
25
- # 使用 pnpm 安装依赖,构建应用
26
  RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
27
 
28
  # 修改文件权限
29
  RUN chown -R node:node /usr/src/app/node_modules /usr/src/app/.pnpm
30
 
31
- # 确保以 node 用户身份运行容器
32
- USER node
33
-
34
  # 复制 docker-bootstrap.sh 脚本
35
  COPY docker-bootstrap.sh /usr/src/app/docker-bootstrap.sh
36
 
37
- # 设置启动脚本权限
38
  RUN chmod +x /usr/src/app/docker-bootstrap.sh
39
 
40
- # 生成 Prisma 客户端
41
- RUN pnpm exec prisma generate
42
-
43
- # 构建应用
44
- RUN pnpm run -r build
45
-
46
- # 部署命令调整为使用克隆的代码
47
- RUN pnpm deploy --filter=server --prod /usr/src/app
48
- RUN pnpm deploy --filter=server --prod /usr/src/app-sqlite
49
-
50
- # 设置工作目录
51
- WORKDIR /usr/src/app
52
-
53
- # 环境变量设置
54
- ENV NODE_ENV=production
55
- ENV HOST="0.0.0.0"
56
- ENV SERVER_ORIGIN_URL=""
57
- ENV MAX_REQUEST_PER_MINUTE=200
58
- ENV AUTH_CODE=""
59
- ENV DATABASE_URL=""
60
- ENV CRON_EXPRESSION="0 8 * * *"
61
-
62
- # 暴露端口
63
- EXPOSE 4000
64
-
65
- # 执行启动脚本
66
  CMD ["./docker-bootstrap.sh"]
 
5
  ENV PNPM_HOME="/pnpm"
6
  ENV PATH="$PNPM_HOME:$PATH"
7
 
8
+ # 安装 OpenSSL 和 git
9
  RUN apk update && apk add --no-cache \
10
  openssl \
11
  git \
12
  && rm -rf /var/cache/apk/*
13
 
14
+ # 安装 pnpm
 
15
  RUN npm install -g pnpm
16
 
17
  # 克隆 GitHub 仓库
18
  WORKDIR /usr/src/app
19
  RUN git clone https://github.com/ShowMeTheMoney2023/top.git .
20
 
21
+ # 创建空的 node_modules 目录
22
  RUN mkdir -p /usr/src/app/node_modules /usr/src/app/.pnpm
23
 
24
+ # 使用 pnpm 安装依赖
25
  RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
26
 
27
  # 修改文件权限
28
  RUN chown -R node:node /usr/src/app/node_modules /usr/src/app/.pnpm
29
 
 
 
 
30
  # 复制 docker-bootstrap.sh 脚本
31
  COPY docker-bootstrap.sh /usr/src/app/docker-bootstrap.sh
32
 
33
+ # 确保该脚本有执行权限
34
  RUN chmod +x /usr/src/app/docker-bootstrap.sh
35
 
36
+ # 设置启动命令
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  CMD ["./docker-bootstrap.sh"]