1、Dockerfile
# 构建镜像,执行命令:【docker build -t jdk8:1.0 .】
FROM openjdk:8-jdk
MAINTAINER raorao
# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
ENTRYPOINT ["java", "-server", "-Xms1024M", "-Xmx1024M", "-Djava.security.egd=file:/dev/./urandom", "-Dfile.encoding=UTF-8","-Denv=DEV", "-XX:+HeapDumpOnOutOfMemoryError","-Xdebug", "-jar", "/app/app.jar" ]
2、docker-compose.yml
version: '3.8'
services:
abtrader-c2b:
image: jdk8:1.0
env_file:
- ./env.env
#environment:
# - env=DEV
#ports:
# - "9970:9970"
volumes:
- "./aaaaaaaaaaaa.jar:/app/app.jar"
- "./application.yml:/app/application.yml"
#networks:
# - c2b
network_mode: host
#networks:
# c2b:
# driver: bridge
3、脚本
#bin
cd 项目目录
echo "拉最新代码"
git pull
echo "开始打包"
mvn clean install -DskipTests
echo "开始部署"
cd ../
mkdir -p docker
cp 项目目录/target/aaaaa-1.0-SNAPSHOT.jar docker/aaaa.jar
cd docker/
docker-compose -f docker-compose.yaml up -d
docker-compose -f docker-compose.yaml restart