unzip wso2mi-4.2.0.zip unzip wso2mi-dashboard-4.2.0-SNAPSHOT.zip mv -f wso2mi-dashboard-4.2.0-SNAPSHOT wso2mi-dashboard-4.2.0
# 设置docker的运行环境 FROM adoptopenjdk/openjdk11:latest # 编写人 MAINTAINER wxhntmy RUN apt update && apt -y upgrade RUN apt -y install wget vim net-tools unzip RUN mkdir -p /app # 将宿主机的文件拷贝到容器的具体目录中。 ADD wso2mi-4.2.0 /app/wso2mi-4.2.0 ADD wso2mi-dashboard-4.2.0 /app/wso2mi-dashboard-4.2.0 WORKDIR /app RUN touch /app/wso2mi-4.2.0/wso2mi-4.2.0.log RUN touch /app/wso2mi-dashboard-4.2.0/wso2mi-dashboard-4.2.0.log # 非root用户启动 RUN groupadd -g 100120 wso2 RUN useradd -u 200211 -g wso2 -d /home/wso2 -m wso2 RUN chown -R wso2:wso2 /app/wso2mi-4.2.0/ RUN chmod 755 /app/wso2mi-4.2.0/ -R RUN chown -R wso2:wso2 /app/wso2mi-dashboard-4.2.0/ RUN chmod 755 /app/wso2mi-dashboard-4.2.0/ -R EXPOSE 80 EXPOSE 9743 EXPOSE 9164 EXPOSE 8290 EXPOSE 8253 EXPOSE 9201 EXPOSE 9164 EXPOSE 8280 EXPOSE 8243 ADD start.sh /app/ RUN chmod +x /app/start.sh USER wso2 CMD ["/bin/bash", "-c", "/app/start.sh"]
#!/bin/bash nohup /app/wso2mi-4.2.0/bin/micro-integrator.sh >/app/wso2mi-4.2.0/wso2mi-4.2.0.log 2>&1 & nohup /app/wso2mi-dashboard-4.2.0/bin/dashboard.sh >/app/wso2mi-dashboard-4.2.0/wso2mi-dashboard-4.2.0.log 2>&1 & while true do procedure_name=("/app/wso2mi-dashboard-4.2.0 /app/wso2mi-4.2.0") for name in $procedure_name do ProcNumber=$(ps -ef |grep -w $name | grep -v "grep" |wc -l) if [ ${ProcNumber} -gt 1 ];then echo -e "`date \"+%Y-%m-%d %H:%M:%S\"` \e[32m The $name is started! \e[0m" else echo -e "`date \"+%Y-%m-%d %H:%M:%S\"` \e[31m The $name is stop! \e[0m" fi done echo -e "`date \"+%Y-%m-%d %H:%M:%S\"` \e[34m Sleep 3 seconds.... \e[0m \n" sleep 3s done
docker build -f wso2_dockerfile -t wso2mi:4.2.0 .
docker run -dit -p 9743:9743 -p 8290:8290 -p 8280:8280 --name wso2mi wso2mi:4.2.0
创建挂载目录
mkdir -p /data/wso2mi-4.2.0/{conf,carbonapps,lib} docker cp wso2mi:/app/wso2mi-4.2.0/conf /data/wso2mi-4.2.0 docker cp wso2mi:/app/wso2mi-4.2.0/lib /data/wso2mi-4.2.0 docker cp wso2mi:/app/wso2mi-4.2.0/repository/deployment/server/carbonapps /data/wso2mi-4.2.0 docker stop wso2mi && docker rm -f wso2mi # 授权 chown -R 200211:100120 /data/wso2mi-4.2.0/ chmod -R 755 /data/wso2mi-4.2.0/
docker run -dit -p 9743:9743 -p 8290:8290 -p 8280:8280 --name wso2mi \ -v /data/wso2mi-4.2.0/conf:/app/wso2mi-4.2.0/conf \ -v /data/wso2mi-4.2.0/lib:/app/wso2mi-4.2.0/lib \ -v /data/wso2mi-4.2.0/carbonapps:/app/wso2mi-4.2.0/repository/deployment/server/carbonapps \ wso2mi:4.2.0
docker ps -a docker logs -f wso2mi docker exec -it wso2mi /bin/bash docker stop wso2mi && docker rm -f wso2mi