49 lines
1.1 KiB
Docker
49 lines
1.1 KiB
Docker
# 基於官方 Ubuntu 映像
|
|
FROM ubuntu:22.04
|
|
|
|
# 設定工作目錄
|
|
WORKDIR /app
|
|
|
|
# 安裝 Python3、pip 及 PySide6/Qt 相關依賴
|
|
RUN apt-get update && \
|
|
apt-get install -y \
|
|
python3 python3-pip \
|
|
libglib2.0-0 \
|
|
libgl1 \
|
|
libegl1 \
|
|
libxkbcommon-x11-0 \
|
|
libxcb-xinerama0 \
|
|
libxcb-cursor0 \
|
|
libxcb-randr0 \
|
|
libxcb-icccm4 \
|
|
libxcb-image0 \
|
|
libxcb-keysyms1 \
|
|
libxcb-render-util0 \
|
|
libxcb-shm0 \
|
|
libxcb-sync1 \
|
|
libxcb-util1 \
|
|
libxcb1 \
|
|
libx11-xcb1 \
|
|
libxcb-render0 \
|
|
libxcb-shape0 \
|
|
xkb-data \
|
|
fontconfig libfontconfig1 \
|
|
libdbus-1-3 \
|
|
# 清理 apt 快取,減少映像大小
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 將 python3 設為預設 python
|
|
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
|
|
|
|
# Copy requirements.txt and install Python dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# 複製你的應用程式到容器中
|
|
COPY . .
|
|
|
|
# 設定環境變數,讓 Qt 在無頭模式下運行
|
|
ENV QT_QPA_PLATFORM=offscreen
|
|
|
|
# 預設執行指令,請將 app.py 替換為你的主程式
|
|
CMD ["python", "app.py"] |