Commit 3bfed3c8 authored by xzxiaoshan's avatar xzxiaoshan Committed by Jason Song

support passing database, meta server info via system environment

docker-compose.yml sample:
------------------------------------------------------------------------------------------
version: '3'
services:
  apollo-portal:
    image: docker.io/xzxiaoshan/apollo-portal:1.4.0
    container_name: apollo-portal
    network_mode: "host"
    environment:
      SERVER_PORT: 5555
      # DataSource Info
      DS_URL: "jdbc:mysql://pro.shanhy.com:3306/ApolloPortalDB?characterEncoding=utf8"
      DS_USERNAME: "shanhy"
      DS_PASSWORD: "xzxiaoshan@123"
      # Environmental variable declaration (meta server url, different environments should have different meta server addresses)
      DEV_META: "http://dev.shanhy.com:6666"
      FAT_META: ""
      UAT_META: ""
      LPT_META: ""
      PRO_META: "http://pro.shanhy.com:6666"
    depends_on:
      - apollo-adminservice
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"

  apollo-configservice:
    image: docker.io/xzxiaoshan/apollo-configservice:1.4.0
    container_name: apollo-configservice
    network_mode: "host"
    environment:
      SERVER_PORT: 6666
      # DataSource Info
      DS_URL: "jdbc:mysql://pro.shanhy.com:3306/ApolloPortalDB?characterEncoding=utf8"
      DS_USERNAME: "shanhy"
      DS_PASSWORD: "xzxiaoshan@123"
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"

  apollo-adminservice:
    image: docker.io/xzxiaoshan/apollo-adminservice:1.4.0
    container_name: apollo-adminservice
    network_mode: "host"
    environment:
      SERVER_PORT: 6667
      # DataSource Info
      DS_URL: "jdbc:mysql://pro.shanhy.com:3306/ApolloPortalDB?characterEncoding=utf8"
      DS_USERNAME: "shanhy"
      DS_PASSWORD: "xzxiaoshan@123"
    depends_on:
      - apollo-configservice
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"
parent b84f5b3f
...@@ -8,6 +8,10 @@ MAINTAINER ameizi <sxyx2008@163.com> ...@@ -8,6 +8,10 @@ MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.5.0-SNAPSHOT ENV VERSION 1.5.0-SNAPSHOT
ENV SERVER_PORT 8090 ENV SERVER_PORT 8090
# DataSource Info
ENV DS_URL ""
ENV DS_USERNAME ""
ENV DS_PASSWORD ""
RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \
......
...@@ -17,6 +17,11 @@ mkdir -p $LOG_DIR ...@@ -17,6 +17,11 @@ mkdir -p $LOG_DIR
########### The following is the same for configservice, adminservice, portal ########### ########### The following is the same for configservice, adminservice, portal ###########
export JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom" export JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom"
# DataSource URL USERNAME PASSWORD
if [ "$DS_URL"x != x ]
then
export JAVA_OPTS="$JAVA_OPTS -Dspring.datasource.url=$DS_URL -Dspring.datasource.username=$DS_USERNAME -Dspring.datasource.password=$DS_PASSWORD"
fi
export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/" export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"
PATH_TO_JAR=$SERVICE_NAME".jar" PATH_TO_JAR=$SERVICE_NAME".jar"
......
...@@ -8,6 +8,10 @@ MAINTAINER ameizi <sxyx2008@163.com> ...@@ -8,6 +8,10 @@ MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.5.0-SNAPSHOT ENV VERSION 1.5.0-SNAPSHOT
ENV SERVER_PORT 8080 ENV SERVER_PORT 8080
# DataSource Info
ENV DS_URL ""
ENV DS_USERNAME ""
ENV DS_PASSWORD ""
RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \
......
...@@ -17,6 +17,11 @@ mkdir -p $LOG_DIR ...@@ -17,6 +17,11 @@ mkdir -p $LOG_DIR
########### The following is the same for configservice, adminservice, portal ########### ########### The following is the same for configservice, adminservice, portal ###########
export JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom" export JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom"
# DataSource URL USERNAME PASSWORD
if [ "$DS_URL"x != x ]
then
export JAVA_OPTS="$JAVA_OPTS -Dspring.datasource.url=$DS_URL -Dspring.datasource.username=$DS_USERNAME -Dspring.datasource.password=$DS_PASSWORD"
fi
export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/" export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"
PATH_TO_JAR=$SERVICE_NAME".jar" PATH_TO_JAR=$SERVICE_NAME".jar"
......
...@@ -8,6 +8,16 @@ MAINTAINER ameizi <sxyx2008@163.com> ...@@ -8,6 +8,16 @@ MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.5.0-SNAPSHOT ENV VERSION 1.5.0-SNAPSHOT
ENV SERVER_PORT 8070 ENV SERVER_PORT 8070
# DataSource Info
ENV DS_URL ""
ENV DS_USERNAME ""
ENV DS_PASSWORD ""
# Environmental variable declaration (meta server url, different environments should have different meta server addresses)
ENV DEV_META ""
ENV FAT_META ""
ENV UAT_META ""
ENV LPT_META ""
ENV PRO_META ""
RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \
......
...@@ -17,6 +17,10 @@ mkdir -p $LOG_DIR ...@@ -17,6 +17,10 @@ mkdir -p $LOG_DIR
########### The following is the same for configservice, adminservice, portal ########### ########### The following is the same for configservice, adminservice, portal ###########
export JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom" export JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom"
if [ "$DS_URL"x != x ]
then
export JAVA_OPTS="$JAVA_OPTS -Dspring.datasource.url=$DS_URL -Dspring.datasource.username=$DS_USERNAME -Dspring.datasource.password=$DS_PASSWORD"
fi
export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/" export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"
PATH_TO_JAR=$SERVICE_NAME".jar" PATH_TO_JAR=$SERVICE_NAME".jar"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment