From eb8c0505a670b81b670b11a717a078439c04f810 Mon Sep 17 00:00:00 2001 From: Stratos Date: Tue, 6 Jul 2021 18:57:00 +0800 Subject: [PATCH 1/2] use openjdk:8-jre-slim as base image --- build/Dockerfile | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index cb45010..631e553 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,15 @@ -FROM centos:7.5.1804 +FROM amd64/buildpack-deps:buster-curl as installer + +ARG NACOS_VERSION=2.0.2 +ARG HOT_FIX_FLAG="" + +RUN set -x \ + && curl -SL --output /var/tmp/nacos-server.tar.gz https://github.com/alibaba/nacos/releases/download/${NACOS_VERSION}${HOT_FIX_FLAG}/nacos-server-${NACOS_VERSION}.tar.gz \ + && tar -xzvf /var/tmp/nacos-server.tar.gz -C /home \ + && rm -rf /var/tmp/nacos-server.tar.gz /home/nacos/bin/* /home/nacos/conf/*.properties /home/nacos/conf/*.example /home/nacos/conf/nacos-mysql.sql + +FROM openjdk:8-jre-slim + MAINTAINER pader "huangmnlove@163.com" # set environment @@ -8,9 +19,8 @@ ENV MODE="cluster" \ CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \ CLUSTER_CONF="/home/nacos/conf/cluster.conf" \ FUNCTION_MODE="all" \ - JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" \ NACOS_USER="nacos" \ - JAVA="/usr/lib/jvm/java-1.8.0-openjdk/bin/java" \ + JAVA="/usr/local/openjdk-8/bin/java" \ JVM_XMS="1g" \ JVM_XMX="1g" \ JVM_XMN="512m" \ @@ -18,37 +28,23 @@ ENV MODE="cluster" \ JVM_MMS="320m" \ NACOS_DEBUG="n" \ TOMCAT_ACCESSLOG_ENABLED="false" \ - TIME_ZONE="Asia/Shanghai" - -ARG NACOS_VERSION=2.0.2 -ARG HOT_FIX_FLAG="" + TZ="Asia/Shanghai" WORKDIR $BASE_DIR -RUN set -x \ - && yum update -y \ - && yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel wget iputils nc vim libcurl -RUN wget https://github.com/alibaba/nacos/releases/download/${NACOS_VERSION}${HOT_FIX_FLAG}/nacos-server-${NACOS_VERSION}.tar.gz -P /home -RUN tar -xzvf /home/nacos-server-${NACOS_VERSION}.tar.gz -C /home \ - && rm -rf /home/nacos-server-${NACOS_VERSION}.tar.gz /home/nacos/bin/* /home/nacos/conf/*.properties /home/nacos/conf/*.example /home/nacos/conf/nacos-mysql.sql -RUN yum autoremove -y wget \ - && ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone \ - && yum clean all - - - +# copy nacos bin +COPY --from=installer ["/home/nacos", "/home/nacos"] ADD bin/docker-startup.sh bin/docker-startup.sh ADD conf/application.properties conf/application.properties ADD init.d/custom.properties init.d/custom.properties - # set startup log dir RUN mkdir -p logs \ - && cd logs \ - && touch start.out \ - && ln -sf /dev/stdout start.out \ - && ln -sf /dev/stderr start.out + && cd logs \ + && touch start.out \ + && ln -sf /dev/stdout start.out \ + && ln -sf /dev/stderr start.out RUN chmod +x bin/docker-startup.sh EXPOSE 8848 From 7f21ee79d5526c7101d3df5550966d1800afaeb8 Mon Sep 17 00:00:00 2001 From: Stratos Date: Thu, 29 Jul 2021 19:30:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=A2=9D=E5=A4=96?= =?UTF-8?q?=E7=9A=84Dockerfile.Slim=E6=96=87=E4=BB=B6=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E4=BF=AE=E6=94=B9=E4=B8=BB=E5=88=86=E6=94=AF=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/Dockerfile | 44 ++++++++++++++++++++------------------ build/Dockerfile.Slim | 49 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 20 deletions(-) create mode 100644 build/Dockerfile.Slim diff --git a/build/Dockerfile b/build/Dockerfile index 631e553..cb45010 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,15 +1,4 @@ -FROM amd64/buildpack-deps:buster-curl as installer - -ARG NACOS_VERSION=2.0.2 -ARG HOT_FIX_FLAG="" - -RUN set -x \ - && curl -SL --output /var/tmp/nacos-server.tar.gz https://github.com/alibaba/nacos/releases/download/${NACOS_VERSION}${HOT_FIX_FLAG}/nacos-server-${NACOS_VERSION}.tar.gz \ - && tar -xzvf /var/tmp/nacos-server.tar.gz -C /home \ - && rm -rf /var/tmp/nacos-server.tar.gz /home/nacos/bin/* /home/nacos/conf/*.properties /home/nacos/conf/*.example /home/nacos/conf/nacos-mysql.sql - -FROM openjdk:8-jre-slim - +FROM centos:7.5.1804 MAINTAINER pader "huangmnlove@163.com" # set environment @@ -19,8 +8,9 @@ ENV MODE="cluster" \ CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \ CLUSTER_CONF="/home/nacos/conf/cluster.conf" \ FUNCTION_MODE="all" \ + JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" \ NACOS_USER="nacos" \ - JAVA="/usr/local/openjdk-8/bin/java" \ + JAVA="/usr/lib/jvm/java-1.8.0-openjdk/bin/java" \ JVM_XMS="1g" \ JVM_XMX="1g" \ JVM_XMN="512m" \ @@ -28,23 +18,37 @@ ENV MODE="cluster" \ JVM_MMS="320m" \ NACOS_DEBUG="n" \ TOMCAT_ACCESSLOG_ENABLED="false" \ - TZ="Asia/Shanghai" + TIME_ZONE="Asia/Shanghai" + +ARG NACOS_VERSION=2.0.2 +ARG HOT_FIX_FLAG="" WORKDIR $BASE_DIR -# copy nacos bin -COPY --from=installer ["/home/nacos", "/home/nacos"] +RUN set -x \ + && yum update -y \ + && yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel wget iputils nc vim libcurl +RUN wget https://github.com/alibaba/nacos/releases/download/${NACOS_VERSION}${HOT_FIX_FLAG}/nacos-server-${NACOS_VERSION}.tar.gz -P /home +RUN tar -xzvf /home/nacos-server-${NACOS_VERSION}.tar.gz -C /home \ + && rm -rf /home/nacos-server-${NACOS_VERSION}.tar.gz /home/nacos/bin/* /home/nacos/conf/*.properties /home/nacos/conf/*.example /home/nacos/conf/nacos-mysql.sql +RUN yum autoremove -y wget \ + && ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone \ + && yum clean all + + + ADD bin/docker-startup.sh bin/docker-startup.sh ADD conf/application.properties conf/application.properties ADD init.d/custom.properties init.d/custom.properties + # set startup log dir RUN mkdir -p logs \ - && cd logs \ - && touch start.out \ - && ln -sf /dev/stdout start.out \ - && ln -sf /dev/stderr start.out + && cd logs \ + && touch start.out \ + && ln -sf /dev/stdout start.out \ + && ln -sf /dev/stderr start.out RUN chmod +x bin/docker-startup.sh EXPOSE 8848 diff --git a/build/Dockerfile.Slim b/build/Dockerfile.Slim new file mode 100644 index 0000000..14f466c --- /dev/null +++ b/build/Dockerfile.Slim @@ -0,0 +1,49 @@ +FROM amd64/buildpack-deps:buster-curl as installer + +ARG NACOS_VERSION=2.0.2 +ARG HOT_FIX_FLAG="" + +RUN set -x \ + && curl -SL --output /var/tmp/nacos-server.tar.gz https://github.com/alibaba/nacos/releases/download/${NACOS_VERSION}${HOT_FIX_FLAG}/nacos-server-${NACOS_VERSION}.tar.gz \ + && tar -xzvf /var/tmp/nacos-server.tar.gz -C /home \ + && rm -rf /var/tmp/nacos-server.tar.gz /home/nacos/bin/* /home/nacos/conf/*.properties /home/nacos/conf/*.example /home/nacos/conf/nacos-mysql.sql + +FROM openjdk:8-jre-slim + +# set environment +ENV MODE="cluster" \ + PREFER_HOST_MODE="ip"\ + BASE_DIR="/home/nacos" \ + CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \ + CLUSTER_CONF="/home/nacos/conf/cluster.conf" \ + FUNCTION_MODE="all" \ + NACOS_USER="nacos" \ + JAVA="/usr/local/openjdk-8/bin/java" \ + JVM_XMS="1g" \ + JVM_XMX="1g" \ + JVM_XMN="512m" \ + JVM_MS="128m" \ + JVM_MMS="320m" \ + NACOS_DEBUG="n" \ + TOMCAT_ACCESSLOG_ENABLED="false" \ + TZ="Asia/Shanghai" + +WORKDIR $BASE_DIR + +# copy nacos bin +COPY --from=installer ["/home/nacos", "/home/nacos"] + +ADD bin/docker-startup.sh bin/docker-startup.sh +ADD conf/application.properties conf/application.properties +ADD init.d/custom.properties init.d/custom.properties + +# set startup log dir +RUN mkdir -p logs \ + && cd logs \ + && touch start.out \ + && ln -sf /dev/stdout start.out \ + && ln -sf /dev/stderr start.out +RUN chmod +x bin/docker-startup.sh + +EXPOSE 8848 +ENTRYPOINT ["bin/docker-startup.sh"]