系统说明
基于 Spring Cloud 、Spring Boot、 OAuth2 的 RBAC 企业快速开发平台, 同时支持微服务架构和单体架构
提供对 Spring Authorization Server 生产级实践,支持多种安全授权模式
提供对常见容器化方案支持 Kubernetes、Rancher2 、Kubesphere、EDAS、SAE 支持
导入软件包
[root@master ~]# tar -xf Pig.tar.gz
[root@master ~]# ll
total 206752
-rw------- 1 root root 211696640 Jan 12 17:24 CentOS_7.9.2009.tar
drwxr-xr-x 2 root root 85 Jan 5 08:58 mysql
drwxr-xr-x 3 root root 37 Jan 5 08:56 nginx
drwxr-xr-x 2 root root 97 Jan 5 08:56 service
drwxr-xr-x 3 root root 12288 Jan 5 08:56 yum
导入CentOS:7.9.2009镜像
[root@master ~]# docker load -i Pig/CentOS_7.9.2009.tar
Loaded image: centos:centos7.9.2009
容器化部署MariaDB
编写init.sh脚本:
[root@k8s-master-node1 Pig]# cat mysql_init.sh
#!/bin/bash
mysql_install_db --user=root
mysqld_safe --user=root &
sleep 8
mysqladmin -u root password 'root'
mysql -uroot -proot -e "grant all on *.* to 'root'@'%' identified by 'root';flush privileges;"
mysql -uroot -proot -e "source /opt/pig.sql;source /opt/pig_codegen.sql;source /opt/pig_config.sql;source /opt/pig_job.sql;"
编写yum源:
[root@k8s-master-node1 Pig]# cat local.repo
[pig]
name=pig
baseurl=file:///root/yum
gpgcheck=0
编写Dockerfile文件:
[root@k8s-master-node1 Pig]# cat Dockerfile-mariadb
FROM centos:centos7.9.2009
MAINTAINER Chinaskills
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY yum /root/yum
ENV LC_ALL en_US.UTF-8
RUN yum -y install mariadb-server
COPY mysql /opt/
COPY mysql_init.sh /opt/
RUN bash /opt/mysql_init.sh
EXPOSE 3306
CMD ["mysqld_safe","--user=root"]
构建镜像:
[root@master Pig]# docker build -t pig-mysql:v1.0 -f Dockerfile-mariadb .
容器化部署Redis
编写Dockerfile
编写Dockerfile文件:
[root@k8s-master-node1 Pig]# cat Dockerfile-redis
FROM centos:centos7.9.2009
MAINTAINER Chinaskills
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY yum /root/yum
RUN yum -y install redis
RUN sed -i 's/127.0.0.1/0.0.0.0/g' /etc/redis.conf && \sed -i 's/protected-mode yes/protected-mode no/g' /etc/redis.conf
EXPOSE 6379
CMD ["/usr/bin/redis-server","/etc/redis.conf"]
构建镜像
[root@master Pig]# docker build -t pig-redis:v1.0 -f Dockerfile-redis .
容器化部署Pig
编写启动脚本:
[root@k8s-master-node1 Pig]# cat pig_init.sh
#!/bin/bash
sleep 20
nohup java -jar /root/pig-register.jar $JAVA_OPTS >/dev/null 2>&1 &
sleep 20
nohup java -jar /root/pig-gateway.jar $JAVA_OPTS >/dev/null 2>&1 &
sleep 20
nohup java -jar /root/pig-auth.jar $JAVA_OPTS >/dev/null 2>&1 &
sleep 20
nohup java -jar /root/pig-upms-biz.jar $JAVA_OPTS >/dev/null 2>&1
编写Dockerfile文件:
[root@k8s-master-node1 Pig]# cat Dockerfile-pig
FROM centos:centos7.9.2009
MAINTAINER Chinaskills
COPY service /root
ADD yum /root/yum
RUN rm -rfv /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/local.repo
RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
COPY pig_init.sh /root
RUN chmod +x /root/pig_init.sh
EXPOSE 8848 9999 3000 4000
CMD ["/bin/bash","/root/pig_init.sh"]
构建镜像
[root@k8s-master-node1 Pig]# docker build -t pig-service:v1.0 -f Dockerfile-pig .
容器化部署前端服务-Nginx
编写Dockerfile文件:
[root@k8s-master-node1 Pig]# cat Dockerfile-nginx
FROM centos:centos7.9.2009
MAINTAINER Chinaskills
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY yum /root/yum
RUN yum -y install nginx
COPY nginx/dist /data
ADD nginx/pig-ui.conf /etc/nginx/conf.d/
RUN /bin/bash -c 'echo init ok'
EXPOSE 80
CMD ["nginx","-g","daemon off;"]
构建镜像
[root@k8s-master-node1 Pig]# docker build -t pig-ui:v1.0 -f Dockerfile-nginx .
编排部署Pig快速开发平台
[root@k8s-master-node1 Pig]# cat docker-compose.yaml
version: '2'
services:pig-mysql:environment:MYSQL_ROOT_PASSWORD: rootrestart: alwayscontainer_name: pig-mysqlimage: pig-mysql:v1.0ports:- 3306:3306links:- pig-service:pig-registerpig-redis:image: pig-redis:v1.0ports:- 6379:6379restart: alwayscontainer_name: pig-redishostname: pig-redislinks:- pig-service:pig-registerpig-service:ports:- 8848:8848- 9999:9999restart: alwayscontainer_name: pig-servicehostname: pig-serviceimage: pig-service:v1.0extra_hosts:- pig-register:127.0.0.1- pig-upms:127.0.0.1- pig-gateway:127.0.0.1- pig-auth:127.0.0.1- pig-hou:127.0.0.1stdin_open: truetty: trueprivileged: truepig-ui:restart: alwayscontainer_name: pig-uiimage: pig-ui:v1.0ports:- 8888:80links:- pig-service:pig-gateway
部署服务
[root@k8s-master-node1 Pig]# docker-compose up -d
等待3分钟左右,在浏览器上通过
http://master_IP:8888
访问Pig,如图所示:
账号/密码:admin / 123456