80 lines
1.9 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.

# ODA File Converter DWG 转换服务
#
# 使用 ODA File Converter 将 DWG 转换为 GLB
# 镜像大小约 300MB(比 FreeCAD 的 2GB+ 小很多)
#
# 构建:
# docker build -f docker/Dockerfile.oda -t dwg-converter .
#
# 运行:
# docker run -p 3001:3001 -v ./uploads:/app/uploads dwg-converter
FROM node:18-slim
# 安装系统依赖(包括虚拟显示服务器)
RUN apt-get update && apt-get install -y \
wget \
curl \
python3 \
python3-pip \
xvfb \
libgl1-mesa-glx \
libglu1-mesa \
libfreetype6 \
fontconfig \
libxrender1 \
libsm6 \
libice6 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-render-util0 \
libxcb-xinerama0 \
libxkbcommon-x11-0 \
libxcb-cursor0 \
libxcb-shape0 \
&& rm -rf /var/lib/apt/lists/*
# 安装 Node.js 转换工具
RUN npm install -g obj2gltf gltf-pipeline
# 安装 Python 依赖
RUN pip3 install --break-system-packages \
flask \
gunicorn \
ezdxf \
trimesh \
numpy
# 创建工作目录
WORKDIR /app
# 下载并安装 ODA File Converter (v26.12)
RUN wget -q "https://www.opendesign.com/guestfiles/get?filename=ODAFileConverter_QT6_lnxX64_8.3dll_26.12.deb" \
-O /tmp/ODAFileConverter.deb \
&& dpkg -i /tmp/ODAFileConverter.deb || apt-get install -f -y \
&& rm -f /tmp/ODAFileConverter.deb \
&& echo "ODA File Converter 安装成功"
# 复制转换服务脚本
COPY docker/oda-converter-server.py /app/
# 创建目录
RUN mkdir -p /app/uploads /app/outputs
# 环境变量
ENV PYTHONUNBUFFERED=1
ENV ODA_CONVERTER_PATH=/usr/bin/ODAFileConverter
ENV DISPLAY=:99
ENV QT_QPA_PLATFORM=xcb
# 暴露端口
EXPOSE 3001
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3001/health || exit 1
# 启动脚本:先启动 Xvfb,再启动服务
CMD Xvfb :99 -screen 0 1024x768x24 & sleep 1 && gunicorn -w 2 -b 0.0.0.0:3001 oda-converter-server:app