Files
apiautotest/dockerfile

38 lines
1.3 KiB
Plaintext
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.
FROM python:3.9
# 使用国内镜像源(debian 镜像源)
RUN sed -i s:/deb.debian.org:/mirrors.tuna.tsinghua.edu.cn:g /etc/apt/sources.list.d/*
#设置时区
RUN echo "Asia/Shanghai" > /etc/timezone
# 安装JDK
RUN apt-get update && apt-get install -y default-jdk
# 安装git
RUN apt-get install -y git
# # 克隆代码(即使挂载整个项目目录也需要拉取代码allure html报告需要确保容器内项目目录下存在lib/allure_xxx/bin/allure文件)
RUN git clone --recurse-submodules https://gitlink.org.cn/kytest/apiautotest.git
# 设置工作目录
WORKDIR /apiautotest
COPY . .
RUN git rev-parse HEAD
RUN ls -a lib && ls -a lib/allure-2.34.1/bin
# 安装pipenv
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv
# 安装依赖
RUN pipenv install
# 运行
CMD ["pipenv", "run", "python", "run.py"]
# 构建docker镜像 docker build -f dockerfile --no-cache -t apitest:2.0 .
# 运行docker镜像docker run --rm --name apitest -e NGINX="http://172.20.32.201:8001" -v /data/nginx/html/apiautotest/:/apiautotest/ -v /data/chytest/env/test.yaml:/apiautotest/env/test.yaml apitest:2.0
# 删除容器docker rm apitest
# 删除docker镜像docker rmi -f apitest:2.0
# 使用 Docker 原生命令仅删除不检查docker rmi your-image-name:your-tag 2>/dev/null || echo "镜像不存在"