xiaozhi-esp32-server/Dockerfile-web
SerenNoble 2ebe42b78d fix: Dockerfile-web 基础镜像换 eclipse-temurin:21-jre-alpine
bellsoft/liberica-runtime-container:jre-21-glibc 拉取不稳定(transient 404),
换 Docker Hub 主流的 eclipse-temurin:21-jre-alpine(apk 兼容,musl 实测可用),
让别的机器 docker build 能稳定成功 → 可移植部署。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-29 21:09:35 +08:00

50 lines
No EOL
1.5 KiB
Text
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.

# 第一阶段:构建Vue前端
FROM node:18 AS web-builder
WORKDIR /app
COPY main/manager-web/package*.json ./
RUN npm install
COPY main/manager-web .
RUN npm run build
# 第二阶段:构建Java后端
FROM maven:3.9.4-eclipse-temurin-21 AS api-builder
WORKDIR /app
COPY main/manager-api/pom.xml .
COPY main/manager-api/src ./src
RUN mvn clean package -Dmaven.test.skip=true
# 第三阶段:构建最终镜像(原 bellsoft/liberica-runtime-container:jre-21-glibc 已从 Docker Hub 下架,换 eclipse-temurin Alpine 版,apk 命令兼容)
FROM eclipse-temurin:21-jre-alpine
# 安装Nginx和字体库
RUN apk update && \
apk add --no-cache --no-scripts \
nginx \
bash \
fontconfig \
ttf-dejavu \
&& rm -rf /var/cache/apk/* \
&& mkdir -p /run/nginx /var/log/nginx /var/tmp/nginx /etc/nginx/conf.d
# 复制项目自带的中文字体
COPY main/manager-web/public/generator/static/fonts/*.ttf /usr/share/fonts/
# 更新字体缓存
RUN fc-cache -f -v
# 配置Nginx
COPY docs/docker/nginx.conf /etc/nginx/nginx.conf
# 复制前端构建产物
COPY --from=web-builder /app/dist /usr/share/nginx/html
# 复制Java后端JAR包
COPY --from=api-builder /app/target/xiaozhi-esp32-api.jar /app/xiaozhi-esp32-api.jar
# 暴露端口
EXPOSE 8002
# 启动脚本(仓库脚本为 CRLF 行尾,转成 LF 避免 exec "no such file or directory")
COPY docs/docker/start.sh /start.sh
RUN sed -i 's/\r$//' /start.sh /etc/nginx/nginx.conf && chmod +x /start.sh
CMD ["/start.sh"]