Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (57 loc) · 2.15 KB
/
Copy pathDockerfile
File metadata and controls
68 lines (57 loc) · 2.15 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
# 使用官方 Jenkins 镜像(快速方法)
FROM jenkins/jenkins:lts-jdk17
USER root
# 配置国内 Debian 镜像源(阿里云)
RUN echo "deb https://mirrors.aliyun.com/debian/ trixie main" > /etc/apt/sources.list && \
echo "deb https://mirrors.aliyun.com/debian/ trixie-updates main" >> /etc/apt/sources.list && \
echo "deb https://mirrors.aliyun.com/debian-security/ trixie-security main" >> /etc/apt/sources.list
# 安装基础工具、编译环境以及 Allure CLI
RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
build-essential \
zlib1g-dev \
libncurses5-dev \
libgdbm-dev \
libnss3-dev \
libssl-dev \
libreadline-dev \
libffi-dev \
libsqlite3-dev \
lsof \
default-jre \
&& rm -rf /var/lib/apt/lists*
# 手动安装 Python 3.9(避免 PPA 复杂性)
RUN cd /tmp && \
wget https://www.python.org/ftp/python/3.9.18/Python-3.9.18.tgz && \
tar xzf Python-3.9.18.tgz && \
cd Python-3.9.18 && \
./configure --enable-optimizations --with-ensurepip=install && \
make -j$(nproc) && \
make altinstall && \
ln -sf /usr/local/bin/python3.9 /usr/bin/python && \
ln -sf /usr/local/bin/python3.9 /usr/bin/python3 && \
ln -sf /usr/local/bin/pip3.9 /usr/bin/pip && \
cd / && rm -rf /tmp/Python-3.9.18*
# 配置 pip 国内源
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn
# 安装项目依赖
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt && \
pip install --no-cache-dir pytest-xdist && \
rm /tmp/requirements.txt
# 安装 Allure CLI
RUN wget -q https://github.com/allure-framework/allure2/releases/download/2.27.0/allure-2.27.0.tgz && \
tar xzf allure-2.27.0.tgz -C /opt && \
rm allure-2.27.0.tgz && \
ln -s /opt/allure-2.27.0/bin/allure /usr/local/bin/allure
# 安装 Playwright 浏览器
RUN playwright install chromium && \
playwright install-deps
# 设置环境变量
ENV PYTHONIOENCODING=utf-8
ENV PYTHONUTF8=1
# 暴露端口
EXPOSE 8080 50000
# 切换回 jenkins 用户
USER jenkins