容器化部署MariaDB
编写init.sh脚本
[root@master ~]# cd Pig/
[root@master Pig]# vi 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;"
编写Dockerfile文件
[root@master Pig]# vi 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
[root@master Pig]# vi 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@master Pig]# vi 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@master Pig]# vi 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@master Pig]# docker build -t pig-service:v1.0 -f Dockerfile-pig .
容器化部署前端服务
编写Dockerfile:
[root@master Pig]# vi 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@master Pig]# docker build -t pig-ui:v1.0 -f Dockerfile-nginx .
编排部署Pig快速开发平台
编写docker-compose.yaml
[root@master Pig]# vi docker-compose.yaml
version: '2'
services:
pig-mysql:
environment:
MYSQL_ROOT_PASSWORD: root
restart: always
container_name: pig-mysql
image: pig-mysql:v1.0
ports:
- 3306:3306
links:
- pig-service:pig-register
pig-redis:
image: pig-redis:v1.0
ports:
- 6379:6379
restart: always
container_name: pig-redis
hostname: pig-redis
links:
- pig-service:pig-register
pig-service:
ports:
- 8848:8848
- 9999:9999
restart: always
container_name: pig-service
hostname: pig-service
image: pig-service:v1.0
extra_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.1
stdin_open: true
tty: true
privileged: true
pig-ui:
restart: always
container_name: pig-ui
image: pig-ui:v1.0
ports:
- 8888:80
links:
- pig-service:pig-gateway
docker-compose up -d
评论区