#!/bin/bash

CI_COMMIT_ID=$1

server="voucher"
image="voucher"
http_port=13000
docker pull registry.cn-chengdu.aliyuncs.com/lsxdjr/$image:"${CI_COMMIT_ID}"
docker stop $server && docker rm $server
# docker run
docker run  --network=merketing-network  -itd --name $server  --restart=always \
           -p $http_port:13000 \
           -v /var/www/marketing/cert:/app/cert \
            registry.cn-chengdu.aliyuncs.com/lsxdjr/$image:"${CI_COMMIT_ID}" \
            ./server -nacosIp "47.110.74.203" -nacosPort 8848 -nacosSpace "voucher" -nacosUsername "" -nacosPassword ""
docker image prune -f
docker container prune -f

#测试 /var/www/marketing/cert
#压测环境 /var/www/cert
#线上 /var/www/cert

docker run -itd --name "voucher" --restart=always \
           -p 13000:13000 \
           -v /var/www/cert:/app/cert \
            registry.cn-chengdu.aliyuncs.com/lsxdjr/voucher-pre:50bb64d6 \
            ./server -nacosIp "172.16.0.239" -nacosPort 8848 -nacosSpace "pre" -nacosUsername "nacos" -nacosPassword "nacos"


# mysql
docker run -itd --name "mysql" --restart=always \
           -p 3306:3306 \
           -v /data/mysql/data:/var/lib/mysql:rw \
           -v /data/mysql/mysql/conf:/etc/mysql/conf.d:rw \
           -v /data/mysql/mysql/logs:/logs:rw \
            mysql:8.0.27