2026-05-20 21:39:12 +08:00

39 lines
1.2 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FROM node:lts-alpine
WORKDIR /app
# 配置alpine国内镜像加速
RUN sed -i "s@http://dl-cdn.alpinelinux.org/@https://repo.huaweicloud.com/@g" /etc/apk/repositories
# 安装tzdata和ffmpeg(提供ffprobe)
# tzdata: 默认的alpine基础镜像不包含时区组件安装后可通过TZ环境变量配置时区
# ffmpeg: 视频处理所需包含ffprobe工具避免npm包中的二进制文件权限/兼容性问题
RUN apk add --no-cache tzdata ffmpeg
# 设置时区为中国东八区这里的配置可以被docker-compose.yml或docker run时指定的时区覆盖
ENV TZ="Asia/Shanghai"
# 安装pnpm
RUN npm install -g pnpm && pnpm config set registry https://registry.npmmirror.com
# 复制package.json
COPY package.json ./package.json
# 安装依赖
RUN pnpm install
# 构建项目
COPY . .
RUN pnpm run build
# 删除开发期依赖,安装生产环境依赖
RUN rm -rf node_modules
RUN pnpm install --prod
# 为node_modules中的ffmpeg/ffprobe二进制文件添加可执行权限
RUN find /app/node_modules -name "ffprobe" -type f -exec chmod +x {} \; 2>/dev/null || true
RUN find /app/node_modules -name "ffmpeg" -type f -exec chmod +x {} \; 2>/dev/null || true
# 如果端口更换,这边可以更新一下
EXPOSE 8002
CMD ["pnpm", "run", "start"]