构建ChromeDriver+chrome的python运行镜像

行云流水
2023-02-16 / 0 评论 / 388 阅读 / 正在检测是否收录...

说明

feapder爬虫运行需要chrome环境的镜像,作者给的镜像加了自己的加密代码。应该是和自己的爬虫管理系统FEAPLAT配合使用。自己构建了一个feapder运行需要的环境镜像。

Dockerfile

FROM selenium/standalone-chrome:latest

# Update
COPY sources.list /etc/apt/sources.list
RUN sudo apt-get update
RUN sudo apt-get -y upgrade

# Set the locale
#RUN apt-get install -y locales && locale-gen "en_US.UTF-8" && dpkg-reconfigure -f noninteractive locales
#ENV LANG en_US.UTF-8
#ENV LANGUAGE en_US:en
#ENV LC_ALL en_US.UTF-8
#ENV PYTHONIOENCODING utf-8
#
#RUN echo \
#    && echo 'LANG=en_US.UTF-8' >> /etc/environment \
#    && echo 'LANGUAGE=en_US:en' >> /etc/environment \
#    && echo 'LC_ALL=en_US.UTF-8' >> /etc/environment \
#    && echo 'PYTHONIOENCODING=utf-8' >> /etc/environment

# Install Python dependencies
RUN sudo apt-get install --upgrade -y python3-pip
#RUN sudo apt-get install -y build-essential libssl-dev libffi-dev python3-dev
#RUN sudo apt-get install -y curl
#RUN sudo apt-get install -y unzip

# 软连接
RUN sudo ln -s /usr/bin/python3.8  /usr/bin/python

# 安装依赖
#RUN sudo pip3 install -r requirements.txt
RUN sudo pip3 install -U pip setuptools  -i https://mirrors.aliyun.com/pypi/simple/
RUN sudo pip3 install feapder  -i https://mirrors.aliyun.com/pypi/simple/


# 目录权限
RUN sudo chmod 777 /usr/local/lib/python3.8/dist-packages/feapder/network/

# 时区
ENV TZ="Asia/Shanghai"

sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

构建

docker build . -t  python-chrome

评论 (0)

取消
只有登录/注册用户才可评论