Browse Source

添加docker自动化部署

dongzhaorui 1 year ago
parent
commit
01b4ae6988
4 changed files with 100 additions and 76 deletions
  1. 49 0
      ybw/Dockerfile
  2. 20 0
      ybw/README.md
  3. 20 0
      ybw/docker-compose.yml
  4. 11 76
      ybw/requirements.txt

+ 49 - 0
ybw/Dockerfile

@@ -0,0 +1,49 @@
+# 拉取镜像
+FROM centos:centos7.9.2009
+
+# 添加快捷命令
+RUN echo "alias ll='ls -hall'" >> ~/.bashrc && source ~/.bashrc
+
+# 配置容器时间
+RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
+
+# 更新yum源, 并生成缓存
+RUN curl -o /etc/yum.repos.d/CentOS7-Aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo && curl -o /etc/yum.repos.d/epel-7-Aliyun.repo http://mirrors.aliyun.com/repo/epel-7.repo
+RUN yum clean all && yum makecache && yum -y update
+RUN yum install -y wget unzip kde-l10n-Chinese
+
+# 设置编码
+RUN export LANG=zh_CN.UTF-8
+# 设置系统语言
+RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
+# 设置vi编码(防止中文乱码)
+RUN grep -qxF 'set encoding=utf8' /etc/virc || echo 'set encoding=utf8' >> /etc/virc
+
+WORKDIR /opt
+# 安装node, 更换npm源
+RUN curl -fsSL https://rpm.nodesource.com/setup_14.x | bash && yum -y install nodejs && npm config set registry https://registry.npm.taobao.org
+
+# 安装 python3.8.10 gcc相关配置
+RUN yum --exclude=kernel* update -y && yum groupinstall -y 'Development Tools' && yum install -y gcc openssl-devel bzip2-devel libffi-devel gtk3 libXt glibc-common
+# python3.8.10下载与解压缩
+RUN curl -o python3.8.10.tgz https://mirrors.huaweicloud.com/python/3.8.10/Python-3.8.10.tgz && tar -zxvf python3.8.10.tgz
+# 切换工作目录
+WORKDIR /opt/Python-3.8.10
+# 创建编译安装目录, 配置安装位置
+RUN mkdir /usr/local/python38 
+RUN ./configure --prefix=/usr/local/python38 && make -j 8 && make altinstall
+# 添加python3的软连接
+RUN rm -rf /usr/bin/python3 /usr/bin/pip3 && ln -s /usr/local/python38/bin/python3.8 /usr/bin/python3 && ln -s /usr/local/python38/bin/pip3.8 /usr/bin/pip3
+# 更换pip源&更新pip
+RUN pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple && pip3 install --upgrade pip
+# 虚拟环境加入系统环境变量
+ENV PATH="/usr/local/python38/bin:$PATH"
+
+# 设置工作目录
+WORKDIR /mnt
+COPY . .
+
+# 安装node项目依赖
+RUN npm install
+# 安装python项目依赖
+RUN pip3 install -r requirements.txt

+ 20 - 0
ybw/README.md

@@ -0,0 +1,20 @@
+
+### 创建docker容器
+```shell
+docker build -t payappcrawl:1.0 .
+```
+
+### 启动服务
+```shell
+docker-compose up -d
+```
+
+### 关闭服务
+```shell
+docker-compose down
+```
+
+### 重启服务
+```shell
+docker-compose restart
+```

+ 20 - 0
ybw/docker-compose.yml

@@ -0,0 +1,20 @@
+version: "3"
+services:
+  server:
+    image: payappcrawl:latest
+    container_name: ybw_detail
+    volumes: # 映射文件夹
+      - /mnt/ybw:/mnt
+      - /mnt/ybw/start.sh:/start.sh
+    network_mode: "host"
+    restart: always
+    privileged: true
+    shm_size: '4gb'
+    deploy:
+      resources:
+        limits:
+          memory: 4G
+        reservations:
+          memory: 200M
+    command:
+      /start.sh

+ 11 - 76
ybw/requirements.txt

@@ -1,79 +1,14 @@
-aliyun-python-sdk-core==2.13.35
-aliyun-python-sdk-kms==2.14.0
-aniso8601==9.0.1
-backcall==0.2.0
-beautifulsoup4==4.9.3
-better-exceptions==0.3.3
-bs4==0.0.1
-certifi==2021.10.8
-cffi==1.15.0
-chardet==3.0.4
-click==8.0.3
-colorama==0.4.4
-copyheaders==0.0.2
-crcmod==1.7
-cryptography==35.0.0
-cssselect==1.1.0
-DBUtils==2.0.2
-ddddocr==1.1.0
-decorator==5.1.0
-EditorConfig==0.12.3
 elasticsearch==7.10.1
 elasticsearch==7.10.1
-et-xmlfile==1.1.0
-fake-useragent==0.1.11
-Flask==2.0.2
-flatbuffers==2.0
-greenlet==1.1.2
-idna==2.8
-influxdb==5.3.1
-ipython==7.30.1
-itsdangerous==2.0.1
-jedi==0.18.1
-jieba==0.42.1
-Jinja2==3.0.3
-jmespath==0.10.0
-jsbeautifier==1.14.0
 loguru==0.5.3
 loguru==0.5.3
-lxml==4.6.3
-MarkupSafe==2.0.1
-matplotlib-inline==0.1.3
-msgpack==1.0.3
-numpy==1.21.4
-onnxruntime==1.9.0
-openpyxl==3.0.9
-oss2==2.14.0
-parsel==1.6.0
-parso==0.8.3
-pickleshare==0.7.5
-Pillow==8.2.0
-pinyin==0.4.0
-playwright==1.17.0
-prompt-toolkit==3.0.24
-protobuf==3.19.1
-pycparser==2.21
-pycryptodome==3.11.0
-pyee==8.2.2
-PyExecJS==1.5.1
-Pygments==2.10.0
-pymongo==3.8.0
-PyMySQL==1.0.2
-PySocks==1.7.1
-python-dateutil==2.8.2
-pytz==2021.3
+lxml>=4.9.1
 PyYAML==5.4.1
 PyYAML==5.4.1
-redis==3.3.6
-redis-py-cluster==2.1.3
-requests==2.22.0
-retrying==1.3.3
-selenium==3.141.0
-six==1.16.0
-soupsieve==2.3.1
-traitlets==5.1.1
-typing_extensions==4.0.0
-urllib3==1.25.11
-w3lib==1.22.0
-wcwidth==0.2.5
-websockets==10.1
-Werkzeug==2.0.2
-win32-setctime==1.0.3
-wincertstore==0.2
+pymongo==3.12.0
+redis==3.5.3
+requests==2.28.1
+beautifulsoup4==4.9.3
+bs4==0.0.1
+jsbeautifier==1.14.7
+oss2==2.14.0
+urllib3==1.26.13
+parsel==1.7.0
+PyExecJS>=1.5.1