有人能够构建包含机器人框架和 QWeb 安装的 docker 镜像吗?我能够构建图像,但用它运行测试没有成功。它说“资源文件‘Qweb’不存在”。
Dockerfile
from python:3
RUN apt-get install -y wget
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update && apt-get -y install google-chrome-stable
RUN pip install robotframework
RUN pip install qweb
ENTRYPOINT ["robot"]
CMD ["-d", "/opt/robotframework/reports", "--outputdir", "/opt/robotframework/reports", "--loglevel", "INFO", "--include", "QWeb", "/opt/robotframework/tests"]
这是一个简单的 Dockerfile。我使用以下命令运行它:
docker run -v $PWD/robot:/opt/robot/Tests -v $PWD/output:/opt/robot/output -v /dev/shm:/dev/shm qweb
FROM python:3.11.3
# Update our system
RUN apt-get update && apt-get upgrade --yes && pip install --upgrade pip
# Install xvfb
RUN apt-get -y install --no-install-recommends -y software-properties-common \
&& apt-get install --no-install-recommends -y scrot xvfb xauth zip
#Installing chrome and chrome driver for selenium
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update && apt-get install --no-install-recommends -y google-chrome-stable
RUN curl -o /tmp/chromedriver-linux64.zip https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chromedriver-linux64.zip \
&& unzip /tmp/chromedriver-linux64.zip -d /tmp \
&& mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/ \
&& rm -rf /tmp/chromedriver-linux64
# Set the locale
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Install Robot Framework and dependencies
RUN pip3 install --no-cache-dir robotframework==6.0.2 QWeb==2.2.1
# Cleanup
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
ENTRYPOINT xvfb-run robot -d /opt/robot/output /opt/robot/Tests