1.注册中心Dockerfile
FROM java:8 #用于指定传递给构建运行时的变量 ARG JAR_FILE="./fdn-servercenter.jar" ARG APP_NAME="fdn-servercenter" ARG DATASOURCE_URL="jdbc:mysql://10.0.0.11:3306/sys-servercenter?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai" ARG DATASOURCE_USERNAME="mysql数据库账号" ARG DATASOURCE_PASSWORD="mysql数据库密码" ARG RABBITMQ_HOST="rabbitmqIP" ARG RABBITMQ_VHOST="/qiqiao/prod" (rabbitmq目录) ARG RABBITMQ_USERNAME="mqadmin01" (rabbitmq账号) ARG RABBITMQ_PASSWORD="Nwff4#vu@kqLPfFdHt" (rabbitmq密码) ARG PROFILES="jdbc" ARG SERVER_PORT=80 ARG DEFAULT_ZONE="http://127.0.0.1:80/eureka" # 内存配置 ENV JAVA_OPTS "-Xmx512M -Xss256k" #启动环境配置 ENV PROFILES $PROFILES #工作路径 ENV WORK_PATH "/home" #日志路径 ENV LOG_FILE "logs/app.log" #服务端口 ENV SERVER_PORT $SERVER_PORT #应用名称 ENV APP_NAME $APP_NAME #设置环境变量 ENV DATASOURCE_URL $DATASOURCE_URL ENV DATASOURCE_USERNAME $DATASOURCE_USERNAME ENV DATASOURCE_PASSWORD $DATASOURCE_PASSWORD ENV RABBITMQ_HOST $RABBITMQ_HOST ENV RABBITMQ_VHOST $RABBITMQ_VHOST ENV RABBITMQ_USERNAME $RABBITMQ_USERNAME ENV RABBITMQ_PASSWORD $RABBITMQ_PASSWORD ENV DEFAULT_ZONE $DEFAULT_ZONE ENV EUREKA_INSTANCE_HOSTNAME $EUREKA_INSTANCE_HOSTNAME #设置时区 RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #用于指定持久化目录 #VOLUME /tmp #指定于外界交互的端口 EXPOSE ${SERVER_PORT} ADD ${JAR_FILE} ${WORK_PATH}/app.jar RUN sh -c 'touch ${WORK_PATH}/app.jar' #配置容器,使其可执行化 ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar $WORK_PATH/app.jar --spring.profiles.active=$PROFILES --logging.file=$LOG_FILE --spring.application.name=$APP_NAME --server.port=$SERVER_PORT --spring.datasource.url=$DATASOURCE_URL --spring.datasource.username=$DATASOURCE_USERNAME --spring.datasource.password=$DATASOURCE_PASSWORD --spring.rabbitmq.host=$RABBITMQ_HOST --spring.rabbitmq.virtual-host=$RABBITMQ_VHOST --spring.rabbitmq.username=$RABBITMQ_USERNAME --spring.rabbitmq.password=$RABBITMQ_PASSWORD --server.context-path=/ --eureka.client.registryFetchIntervalSeconds=5 --eureka.client.register-with-eureka=false --eureka.client.fetch-registry=false --eureka.client.serviceUrl.defaultZone=$DEFAULT_ZONE --eureka.server.waitTimeInMsWhenSyncEmpty=0 --eureka.server.enableSelfPreservation=false --eureka.instance.prefer-ip-address=false --eureka.instance.hostname=$EUREKA_INSTANCE_HOSTNAME --security.basic.enabled=false" ]