1. Introduction

YAPI is a visual interface management tool developed by Qunar Mobile Architecture team (YMFE, a group of FE, iOS and Android engineers composed of the most imaginative, creative and influential front-end team). It is a locally deployable interface management platform that connects the front end and QA. YAPI is designed to provide more elegant interface management services for developers, products and testers. It can help developers easily create, publish and maintain apis for different projects and platforms. With YAPI, we can easily test, manage and maintain API interfaces of multiple projects. Unlike Swagger, which is born and die with application (and most of them have to be closed in online environment), YAPI is an independent service platform.

Deployment of 2.

This deployment document source website: https://hub.docker.com/r/yapipro/yapi

2.1 Docker installation

slightly

2.2 Creating a Custom Network

Network communication between Docker containers requires creating a custom network

docker network create yapi 
Copy the code

2.3 Preparing a Database for MongoDB

YAPI's database is MongoDB, prepare the image and start the container as follows: #1.To back up mongoDB to the host, run the following command to create a storage volume docker volume create mongo-data #2.Docker pull mongo:latest #3.MONGO_INITDB_ROOT_USERNAME: MONGO_INITDB_ROOT_USERNAME: MONGO_INITDB_ROOT_USERNAME MONGO_INITDB_ROOT_PASSWORD is the ROOT password of MongoDB docker run -d --name MongoDB --restart always --net=yapi -- p27017:27017 \
  -v mongo-data:/data/db \
  -e MONGO_INITDB_DATABASE=yapi \
  -e MONGO_INITDB_ROOT_USERNAME=yapipro \
  -e MONGO_INITDB_ROOT_PASSWORD=yapipro1024 \
  mongo
# 4Docker ps -a #5, enter the MongoDB container from the4Step check the MongoDB container to obtain the container ID, which is used in the following example2C46d9f59874 specifies the MongoDB container ID docker execit2c46d9f59874 /bin/sh
# 6Go to mongo cli mongo localhost:27017
Copy the code

After logging in to the mongo CLI of MongoDB, execute the following statement to initialize the library table:

use admin;
db.auth("yapipro"."yapipro1024"); Create yapi database use yapi; Db.createuser ({user:'yapi',
  pwd: 'yapi123456',
  roles: [
 { role: "dbAdmin", db: "yapi" },
 { role: "readWrite", db: "yapi"}}]); Exit the Mongo Cliexit# Exit containerexit
Copy the code

2.4 start YAPI

In the current directory of the host, create a YAPI configuration file, config.json, based on your own modifications

 {
   "port": "3000"."adminAccount": "[email protected]"."timeout":120000."db": {
     "servername": "mongo"."DATABASE": "yapi"."port": 27017."user": "yapi"."pass": "yapi123456"."authSource": ""
   },
   "mail": {
     "enable": true."host": "smtp.gmail.com"."port": 465."from": "*"."auth": {
       "user": "[email protected]"."pass": "xxx"}}}Copy the code

Pull the latest image and start

Docker run -d --rm \ --name yapi-init \ --link mongodb:mongo \ --net=yapi \ -v $PWD/config. Json: / yapi/config. The json \ yapipro/yapi \ server/install js # initialization administrator account in the above config. The json configuration [email protected], the initial password is yapi.pro, Docker run -d --name yapi --link mongodb:mongo --restart always --net=yapi -p docker run -d --name yapi --link mongodb:mongo --restart always --net=yapi -p3000:3000\ v $PWD/config. Json: / yapi/config. The json \ yapipro yapi \ server/app/js # on the server validation yapi start-up success curl localhost:3000
Copy the code

2.5 access

The user name is [email protected] and the initial password is yapi.pro