-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (60 loc) · 2.16 KB
/
Dockerfile
File metadata and controls
65 lines (60 loc) · 2.16 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
58
59
60
61
62
63
64
65
FROM docker.1ms.run/node:20-alpine AS deps
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
# 安装 Python 3、pip 及构建原生模块所需依赖
RUN apk add --no-cache \
python3 \
py3-pip \
make \
g++ \
gcc \
musl-dev \
&& ln -sf python3 /usr/bin/python
# 可选:验证 Python 和 pip 版本
RUN python --version && pip --version
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm@9.11.0 --registry=https://registry.npmmirror.com
ENV FFMPEG_BINARIES_URL="https://cdn.npmmirror.com/binaries/ffmpeg-static"
RUN pnpm install --registry=https://registry.npmmirror.com
FROM docker.1ms.run/node:20-alpine AS prods
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
# 安装 Python 3、pip 及构建原生模块所需依赖
RUN apk add --no-cache \
python3 \
py3-pip \
make \
g++ \
gcc \
musl-dev \
&& ln -sf python3 /usr/bin/python
# 可选:验证 Python 和 pip 版本
RUN python --version && pip --version
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm@9.11.0 --registry=https://registry.npmmirror.com
ENV FFMPEG_BINARIES_URL="https://cdn.npmmirror.com/binaries/ffmpeg-static"
RUN pnpm install --prod --registry=https://registry.npmmirror.com
FROM docker.1ms.run/node:20-alpine AS builder
ARG APP_ENV
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN npm run build
FROM docker.1ms.run/node:20-alpine AS runner
WORKDIR /usr/app
ARG APP_ENV
COPY --from=builder /app/build ./build
COPY package.json ./
COPY ./config ./config
COPY ./public ./public
COPY --from=prods /app/node_modules ./node_modules
RUN rm -rf /usr/app/public/temp
RUN chown -R node ./
USER node
ENV NODE_ENV="production"
EXPOSE 5050
CMD ["npm", "start"]