-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.build
More file actions
62 lines (54 loc) · 1.68 KB
/
Dockerfile.build
File metadata and controls
62 lines (54 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Dockerfile for building auto-clock with Python 3.10
# Using official Python 3.10 image based on Debian Bullseye (compatible with Ubuntu 20.04)
FROM python:3.10-slim-bullseye
# 设置非交互式安装
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
ENV PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
ENV PIP_TRUSTED_HOST=mirrors.aliyun.com
# 更换为阿里云镜像源以加速下载
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
# 安装系统依赖
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
binutils \
libxcb-xinerama0 \
libxcb-cursor0 \
libxcb1-dev \
libx11-dev \
libxkbcommon-x11-0 \
libegl1-mesa-dev \
libgl1-mesa-glx \
libfontconfig1-dev \
libicu-dev \
libsqlite3-dev \
libxss1 \
libgconf-2-4 \
libxtst6 \
libasound2-dev \
libpulse-dev \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-shape0 \
libdbus-1-3 \
&& rm -rf /var/lib/apt/lists/*
# 设置工作目录
WORKDIR /build
# 复制项目文件
COPY . /build/
# 安装Python依赖
# 使用requirements.txt(Python 3.10兼容)
# 注意:Linux Docker环境使用 opencv-python-headless 替代 opencv-python
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install -r requirements.txt && \
python3 -m pip uninstall -y opencv-python && \
python3 -m pip install opencv-python-headless && \
python3 -m pip install pyinstaller
# 构建脚本,并修复生成文件的权限
CMD bash linux_build.sh && chmod -R 777 /build/dist