This document describes how to deploy code-push-server using Docker, the instance includes three parts
- code-push-server part
- Update packages use
localstorage by default (stored on the local machine). Using docker volume storage method, container destruction won't cause data loss unless the volume is manually deleted. - Uses pm2 cluster mode internally to manage processes, default process count is equal to CPU count, you can configure the deploy parameters in docker-compose.yml file according to your machine configuration.
- docker-compose.yml only provides some application parameter settings, if you need to set other configurations, you can modify the config.js file.
- Update packages use
- mysql part
- Data uses docker volume storage method, container destruction won't cause data loss unless the volume is manually deleted.
- Applications should not use root user, for security you can create a user with relatively small permissions for code-push-server to use, only
select,update,insertpermissions are needed. Initializing the database requires root or a user with table creation permissions
- redis part
tryLoginTimeslogin error count limitupdateCheckCacheimproves application performancerolloutClientUniqueIdCachegray release
Refer to Docker's official installation guide
$ docker info should output relevant information successfully, then the installation is successful and you can proceed with the following steps
$ sudo docker swarm init$ git clone https://github.com/lisong/code-push-server.git
$ cd code-push-server/docker$ vim docker-compose.ymlReplace YOU_MACHINE_IP in DOWNLOAD_URL with your machine's external IP or domain
Replace YOU_MACHINE_IP in MYSQL_HOST with your machine's internal IP
Replace YOU_MACHINE_IP in REDIS_HOST with your machine's internal IP
code-push-server uses JSON web token encryption method for login verification, this symmetric encryption algorithm is public, so modifying the tokenSecret value in config.js is very important.
Very important! Very important! Very important!
You can open the link
https://www.grc.com/passwords.htmto get a random number of type63 random alpha-numeric charactersas the key
$ sudo docker stack deploy -c docker-compose.yml code-push-serverIf the network speed is poor, you'll need to wait patiently... go chat with your friends meanwhile ^_^
$ sudo docker service ls
$ sudo docker service ps code-push-server_db
$ sudo docker service ps code-push-server_redis
$ sudo docker service ps code-push-server_serverConfirm that
CURRENT STATEisRunning about ..., then deployment is complete
$ curl -I http://YOUR_CODE_PUSH_SERVER_IP:3000/
Returns 200 OK
HTTP/1.1 200 OK
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: text/html; charset=utf-8
Content-Length: 592
ETag: W/"250-IiCMcM1ZUFSswSYCU0KeFYFEMO8"
Date: Sat, 25 Aug 2018 15:45:46 GMT
Connection: keep-aliveDefault username: admin password: 123456 Remember to change the default password If you enter the wrong password too many times in a row, you will be locked out. You need to clear the redis cache
$ redis-cli -p6388 # enter redis
> flushall
> quit$ sudo docker service logs code-push-server_server
$ sudo docker service logs code-push-server_db
$ sudo docker service logs code-push-server_redis| DRIVER | VOLUME NAME | Description |
|---|---|---|
| local | code-push-server_data-mysql | Database storage data directory |
| local | code-push-server_data-storage | Storage package files directory |
| local | code-push-server_data-tmp | Temporary directory for calculating update package differences |
| local | code-push-server_data-redis | Redis persistent data |
$ sudo docker stack rm code-push-server
$ sudo docker swarm leave --force