Files
dysync/Dockerfile.prod
T
yuming 30060fe29c feat: 将本地独有功能移植到 upstream 最新版本
基于 upstream/master (c5922f9) 新建分支,移植以下功能:
1. 扫码登录(DyQrCodeService + ConfigController 3个接口)
2. 视频预览组件(VideoPlayer.vue)
3. 下载配置服务(DownloadConfigService + AppConfig 6个扩展字段)
4. Gitea CI/CD(.gitea/workflows/deploy.yml)
5. 生产 Dockerfile(Dockerfile.prod,含中国镜像源配置)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 20:58:08 +08:00

87 lines
2.3 KiB
Docker
Raw 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.
# 多阶段构建 Dockerfile
# 第一阶段:构建前端
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
COPY app/package.json app/pnpm-lock.yaml* ./
RUN npm config set registry https://registry.npmmirror.com && \
npm install -g pnpm && \
pnpm config set registry https://registry.npmmirror.com && \
if [ -f pnpm-lock.yaml ]; then \
pnpm install --frozen-lockfile; \
else \
npm install; \
fi
COPY app/ ./
RUN pnpm build || npm run build
# 第二阶段:构建后端 + 下载 Playwright Chromium
FROM mcr.azurecr.cn/dotnet/sdk:6.0 AS backend-builder
WORKDIR /src
# 安装 Node.js 18(用于 npx playwright install,最可靠的方式)
RUN apt-get update && apt-get install -y curl && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
COPY *.csproj ./
RUN dotnet restore dy.net.csproj
COPY . .
RUN find . -name "._*" -type f -delete
COPY --from=frontend-builder /app/frontend/dist ./app/dist
RUN dotnet publish dy.net.csproj -c Release -o /app/publish
# 用 npx 下载 Playwright Chromium 到固定路径
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN npx -y playwright@1.44.0 install chromium
# 第三阶段:运行镜像
FROM mcr.azurecr.cn/dotnet/aspnet:6.0 AS final
WORKDIR /app
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 切换阿里云镜像源,解决国内网络无法访问 deb.debian.org 的问题
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
# 安装 Chromium 运行时依赖(Debian Bullseye)
RUN apt-get update && apt-get install -y --no-install-recommends \
libnss3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libgtk-3-0 \
fonts-liberation \
&& rm -rf /var/lib/apt/lists/*
COPY --from=backend-builder /app/publish .
COPY --from=backend-builder /ms-playwright /ms-playwright
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
EXPOSE 10101
ENV ASPNETCORE_URLS=http://*:10101
ENV ASPNETCORE_ENVIRONMENT=Production
ENTRYPOINT ["dotnet", "dy.net.dll"]