xxl-job: 官网:
1: 下载源码, 修改变量,打包
修改变量为参数, 从docker-comopose中注入, 修改后打包上传至liunx
2: dockerfile
FROM java:8-jdk##设置默认语言环境 ENV LANG=C.UTF-8 ENV TimeZone=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TimeZone /etc/localtime && echo $TimeZone > /etc/timezone ARG SERVER_PORT ARG DB_USERNAME ARG DB_PASSWORD ARG DB_HOST ARG DB_PORT ARG DB_DATABASE ARG MAIL_USERNAME ARG MAIL_PASSWORD ARG MAIL_FROM ENV SERVER_PORT=${SERVER_PORT} \ DB_USERNAME=${DB_USERNAME} \ DB_PASSWORD=${DB_PASSWORD} \ DB_HOST=${DB_HOST} \ DB_PORT=${DB_PORT} \ DB_DATABASE=${DB_DATABASE} \ MAIL_USERNAME=${MAIL_USERNAME} \ MAIL_PASSWORD=${MAIL_PASSWORD} \ MAIL_FROM=${MAIL_FROM} ADD xxl-job-admin-*.jar /app.jar ENV JAVA_OPTS="-Xms1024m -Xmx1024m -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/soft/dump" ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /app.jar "]
3: 将 dockerfile 与 xxl-job-admin-2.4.0-SNAPSHOT.jar 放在目录, 打包镜像:
docker build -t xxljob .
打包完成:
4: docker-compose,
镜像为上一步打包的镜像名称,
数据库为mysql, 执行 doc > db中的脚本
services:
xxljob:
container_name: xxljob
environment:
DB_DATABASE: xxl_job
DB_HOST: xxx
DB_PASSWORD: xxx
DB_PORT: '30010'
DB_USERNAME: root
MAIL_FROM: ''
MAIL_PASSWORD: ''
MAIL_USERNAME: ''
SERVER_PORT: '30026'
image: xxljob
logging:
driver: json-file
options:
max-file: '10'
max-size: 200k
pid: host
ports:
- published: 30026
target: 30026
restart: always
volumes:
- /usr/soft/xxljob/applogs:/data/applogs:rw
5: 启动及访问;
放开防火墙端口
docker-compose up -d
访问: ip:端口//xxl-job-admin/jobinfo