-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.build
More file actions
70 lines (60 loc) · 1.93 KB
/
Copy pathDockerfile.build
File metadata and controls
70 lines (60 loc) · 1.93 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
63
64
65
66
67
68
69
70
# 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
ARG APT_MIRROR=
# 设置非交互式安装
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
# 可选更换APT镜像源(例如 mirrors.aliyun.com)
RUN if [ -n "${APT_MIRROR}" ]; then \
sed -i "s/deb.debian.org/${APT_MIRROR}/g" /etc/apt/sources.list && \
sed -i "s/security.debian.org/${APT_MIRROR}/g" /etc/apt/sources.list; \
fi
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
file \
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 \
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
# 构建脚本,并修复生成文件的权限
ENV HOST_UID=1000
ENV HOST_GID=1000
# 构建脚本,并修复生成文件的权限/归属
CMD ["sh", "-c", "bash linux_build.sh && chown -R ${HOST_UID}:${HOST_GID} /build/dist || true && chmod -R 775 /build/dist"]