美文网首页
docker-compose easy-mock

docker-compose easy-mock

作者: liangyongtong | 来源:发表于2019-07-17 00:58 被阅读0次
    使用docker-compose搭建Easy-mock服务

    1.确认本地除了安装docker外还安装了docker-compose

    $ docker-compose -v

    2.在任意一个目录下创建两个文件 docker-compose.yml

    version: '3'
    
    services:
      mongodb:
        image: mongo:3.4
        privileged: true
        volumes:
          # ./data/db 数据库文件存放地址,根据需要修改为本地地址
          - './data/db:/data/db'
        networks:
          - easy-mock
        restart: always
    
      redis:
        image: redis:4.0.6
        privileged: true
        command: redis-server --appendonly yes
        volumes:
          # ./data/redis redis 数据文件存放地址,根据需要修改为本地地址
          - './data/redis:/data'
        networks:
          - easy-mock
        restart: always
    
      web:
        image: easymock/easymock:1.6.0
        privileged: true
        command: /bin/bash -c "npm start"
        ports:
          - 7300:7300
        volumes:
          # 日志地址,根据需要修改为本地地址
          - './logs:/home/easy-mock/easy-mock/logs'
          # 配置地址,请使用本地配置地址替换
          # - './production.json:/home/easy-mock/easy-mock/config/production.json'
        networks:
          - easy-mock
        restart: always
    
    networks:
      easy-mock:
    

    production.json

    {
        "port": 7300,
        "host": "0.0.0.0",
        "pageSize": 30,
        "proxy": false,
        "db": "mongodb://mongodb/easy-mock",
        "unsplashClientId": "",
        "redis": {
          "keyPrefix": "[Easy Mock]",
          "port": 6379,
          "host": "redis",
          "password": "",
          "db": 0
        },
        "blackList": {
          "projects": [],
          "ips": []
        },
        "rateLimit": {
          "max": 1000,
          "duration": 1000
        },
        "jwt": {
          "expire": "14 days",
          "secret": "shared-secret"
        },
        "upload": {
          "types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"],
          "size": 5242880,
          "dir": "../public/upload",
          "expire": {
            "types": [".json", ".yml", ".yaml"],
            "day": -1
          }
        },
        "ldap": {
          "server": "",
          "bindDN": "",
          "password": "",
          "filter": {
            "base": "",
            "attributeName": ""
          }
        },
        "fe": {
          "copyright": "",
          "storageNamespace": "easy-mock_",
          "timeout": 25000,
          "publicPath": "/dist/"
        }
      }
    

    3.在当前目录下创建数据目录和日志目录并且给他们赋予权限:

    $ mkdir -p data/db

    $ mkdir -p data/redis

    $ mkdir logs

    $ chmod -R 777 当前目录

    4.使用docker-compose安装相应的镜像并启动easy-mock服务(过程需要一些时间,安装mongo,redis,easy-mock):

    $ docker-compose up

    5.安装并启动完毕后即可以访问服务 http://0.0.0.0:7300
    6.停止和启动(还是需要到当前目录下,与docker-compose.yml同级)

    $ docker-compose stop

    $ docker-compose start

    它们会同时停止或启动对应的三个服务

    相关文章

      网友评论

          本文标题:docker-compose easy-mock

          本文链接:https://www.haomeiwen.com/subject/rzqflctx.html