From 680fa0c1a787fb179cf9cc36cd65e854c3f2b76f Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Wed, 8 May 2024 15:06:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91Dockerfile?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/cmd/Dockerfile | 19 +++++++++---------- build/cmd/common.sh | 2 +- build/resources/Dockerfile | 17 ++++++++++------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/build/cmd/Dockerfile b/build/cmd/Dockerfile index e1b8faed..576a399f 100644 --- a/build/cmd/Dockerfile +++ b/build/cmd/Dockerfile @@ -8,25 +8,24 @@ RUN yum install -y wget && wget http://dl.fedoraproject.org/pub/epel/epel-releas #声明端口 EXPOSE 9400 8099 -#定义数据卷 -VOLUME /var/lib/apinto - #设置环境变量 -ENV APP=apinto +ARG AppName=apinto + +#定义数据卷 +VOLUME /var/lib/${AppName} -ENV TZ=Asia/Shanghai -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone #解压网关程序压缩包 COPY ./apinto.linux.x64.tar.gz / RUN tar -zxvf apinto.linux.x64.tar.gz && rm -rf apinto.linux.x64.tar.gz #复制程序默认配置文件以及修改脚本权限 -RUN mkdir /etc/apinto -RUN cp /apinto/apinto.yml.tpl /etc/apinto/apinto.yml && cp /apinto/config.yml.tpl /etc/apinto/config.yml -RUN chmod 777 /apinto/start.sh && chmod 777 /apinto/join.sh && chmod 777 /apinto/leave.sh +RUN mkdir /etc/${AppName} +RUN cp /${AppName}/${AppName}.yml.tpl /etc/${AppName}/${AppName}.yml && cp /${AppName}/config.yml.tpl /etc/${AppName}/config.yml +RUN chmod 777 /${AppName}/start.sh && chmod 777 /${AppName}/join.sh && chmod 777 /${AppName}/leave.sh -WORKDIR /apinto +WORKDIR /${AppName} #容器启动命令 CMD sh start.sh diff --git a/build/cmd/common.sh b/build/cmd/common.sh index 3fdfbc81..3d3a4ebe 100755 --- a/build/cmd/common.sh +++ b/build/cmd/common.sh @@ -39,7 +39,7 @@ function buildApp(){ -X 'github.com/eolinker/apinto/utils/version.goVersion=$(go version)' -X 'github.com/eolinker/apinto/utils/version.eoscVersion=${EOSC_VERSION}'" echo -e "build $APP:go build -ldflags "-w -s $flags" -o ${OUTPATH}/$APP ${BasePath}/app/$APP" - CGO_ENABLED=0 go build -ldflags "-w -s $flags" -o ${OUTPATH}/$APP ${BasePath}/app/$APP + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w -s $flags" -o ${OUTPATH}/$APP ${BasePath}/app/$APP # echo "build $APP:${buildCMD}" # echo `${buildCMD}` diff --git a/build/resources/Dockerfile b/build/resources/Dockerfile index f1beafab..576a399f 100644 --- a/build/resources/Dockerfile +++ b/build/resources/Dockerfile @@ -4,25 +4,28 @@ FROM centos:7.9.2009 MAINTAINER eolink RUN yum install -y wget && wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && rpm -ivh epel-release-latest-7.noarch.rpm && yum install -y jq + #声明端口 EXPOSE 9400 8099 +#设置环境变量 +ARG AppName=apinto + #定义数据卷 -VOLUME /var/lib/apinto +VOLUME /var/lib/${AppName} -#设置环境变量 -ENV APP=apinto +RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone #解压网关程序压缩包 COPY ./apinto.linux.x64.tar.gz / RUN tar -zxvf apinto.linux.x64.tar.gz && rm -rf apinto.linux.x64.tar.gz #复制程序默认配置文件以及修改脚本权限 -RUN mkdir /etc/apinto -RUN cp /apinto/apinto.yml.tpl /etc/apinto/apinto.yml && cp /apinto/config.yml.tpl /etc/apinto/config.yml -RUN chmod 777 /apinto/start.sh && chmod 777 /apinto/join.sh && chmod 777 /apinto/leave.sh +RUN mkdir /etc/${AppName} +RUN cp /${AppName}/${AppName}.yml.tpl /etc/${AppName}/${AppName}.yml && cp /${AppName}/config.yml.tpl /etc/${AppName}/config.yml +RUN chmod 777 /${AppName}/start.sh && chmod 777 /${AppName}/join.sh && chmod 777 /${AppName}/leave.sh -WORKDIR /apinto +WORKDIR /${AppName} #容器启动命令 CMD sh start.sh