环境介绍

  • 灯塔在5月14号删除github仓库dockerhub仓库,无法使用docker拉取镜像来搭建。

搭建条件

  • 使用已经搭建灯塔的机器保存docker镜像来进行搭建。

vps 1

  • 已经安装docker环境

  • 已经搭建灯塔

vps 2

  • 未安装docker

  • 为搭建灯塔

开始搭建

vps1

  • 本地的文件,灯塔官方的文件,进行压缩打包。

  • 使用docker images查看镜像

root@EEMM:/opt# docker images 
REPOSITORY                                     TAG                        IMAGE ID       CREATED         SIZE
tophant/arl                                    <none>                     658157563173   4 months ago   1.19GB
mongo                                          4.0.27                     e305b5d51c0a   2 years ago     430MB
rabbitmq                                       3.8.19-management-alpine   cd80881c4e0e   2 years ago     173MB
  • docker镜像重新更改TAG

docker tag 658157563173 tophant/arl:local
docker tag e305b5d51c0a mongo:local
docker tag cd80881c4e0e rabbitmq:local
  • docker 保存命令把镜像保存为本地文件

docker save tophant/arl:local -o arl.tar
docker save mongo:local -o mongo.tar
docker save rabbitmq:local -o rabbitmq.tar

  • 修改docker-compose.yml的文件

  • 主要修改: tophant/arl:${ARL_VERSION:-latest} 改为 image: tophant/arl:local 以此类推。

  • 以下为修改后。


version: '3'

volumes:
  arl_db:
    external: true

services:
    web:
        image: tophant/arl:local
        container_name: arl_web
        restart: unless-stopped
        depends_on:
          - mongodb
          - rabbitmq
        ports:
          #http 服务,默认不映射出来
          - "5003:80"
          #- "5003:443"
        volumes:
          - ./arl_web.log:/code/arl_web.log
          - ./config-docker.yaml:/code/app/config.yaml
          - ./image:/code/app/tmp_screenshot
          - ./poc:/opt/ARL-NPoC/xing/plugins/upload_poc
        entrypoint: ["sh", "-c", "gen_crt.sh; nginx; wait-for-it.sh mongodb:27017; wait-for-it.sh rabbitmq:5672; gunicorn -b 0.0.0.0:5003 app.main:arl_app -w 3 --access-logfile arl_web.log --access-logformat '%({x-real-ip}i)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"'"]
        environment:
          - LANG=en_US.UTF-8
          - TZ=Asia/Shanghai

    worker:
        image: tophant/arl:local
        container_name: arl_worker
        restart: unless-stopped
        depends_on:
          - mongodb
          - rabbitmq
        volumes:
          - ./arl_worker.log:/code/arl_worker.log
          - ./config-docker.yaml:/code/app/config.yaml
          - ./image:/code/app/tmp_screenshot
          - ./poc:/opt/ARL-NPoC/xing/plugins/upload_poc
        entrypoint: ["sh", "-c", "wait-for-it.sh mongodb:27017; wait-for-it.sh rabbitmq:5672;
        celery -A app.celerytask.celery worker -l info -Q arlgithub -n arlgithub -c 2 -O fair -f arl_worker.log &
         celery -A app.celerytask.celery worker -l info -Q arltask -n arltask -c 2 -O fair -f arl_worker.log"]

        environment:
          - LANG=en_US.UTF-8
          - TZ=Asia/Shanghai

    scheduler:
      image: tophant/arl:local
      container_name: arl_scheduler
      restart: unless-stopped
      depends_on:
        - mongodb
        - rabbitmq
      volumes:
        - ./config-docker.yaml:/code/app/config.yaml
      entrypoint: [ "sh", "-c", "wait-for-it.sh mongodb:27017; wait-for-it.sh rabbitmq:5672; python3.6 -m app.scheduler" ]
      environment:
        - LANG=en_US.UTF-8
        - TZ=Asia/Shanghai

    mongodb:
        image: mongo:local
        container_name: arl_mongodb
        restart: always
        volumes:
          - arl_db:/data/db
          - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
        environment:
          - MONGO_INITDB_DATABASE=arl
          - MONGO_INITDB_ROOT_USERNAME=admin
          - MONGO_INITDB_ROOT_PASSWORD=admin


    rabbitmq:
      image: rabbitmq:local
      container_name: arl_rabbitmq
      restart: always
      environment:
        - RABBITMQ_DEFAULT_PASS=arlpassword
        - RABBITMQ_DEFAULT_USER=arl
        - RABBITMQ_DEFAULT_VHOST=arlv2host
      logging:
        driver: "json-file"
        options:
          max-size: "1M"
          max-file: "
  • 打包好的文件

vps 2

  • 全新机器安装docker环境,安装参考菜鸟教程

https://www.runoob.com/docker/docker-compose.html
  • 把打包的文件下载到新机器

  • 解压docker_arl

  • docker 导入镜像

docker load < arl.tar
docker load < mongo.tar
docker load < rabbitmq.tar

  • 创建文件

docker volume create arl_db
  • 启动

注意

  • 数据不会保留

  • 及时更改密码