From 05ed0fc16ff439392518c4ca8998ef2450df0882 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 5 Jul 2019 11:14:21 +0000 Subject: [PATCH] add docker file --- Dockerfile | 15 +++++++++++++++ buildimage-config-server.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Dockerfile create mode 100755 buildimage-config-server.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8882111 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:8 + +RUN apt-get update && apt-get install -y net-tools vim telnet + +LABEL gateway.version=$VERSION +LABEL gateway.build_date=$BUILD_DATE + +WORKDIR /usr/src/app + +ADD . . +RUN npm install + +EXPOSE 3039 + +CMD npm run start diff --git a/buildimage-config-server.sh b/buildimage-config-server.sh new file mode 100755 index 0000000..d736284 --- /dev/null +++ b/buildimage-config-server.sh @@ -0,0 +1,30 @@ +#!/bin/bash +################################################################### +#Script Name : buildimage-configSvr.sh +#Description : 用于给config server生成docker镜像,生成镜像后,可以手动执行下面一条指令启动容器 +#Start container: docker run -d --name gateway -p 8081:8081 -p 8182:8182 -v /data/logs-gateway:/usr/src/app/log -v /opt/gateway/backend/config:/usr/src/app/config --link postgres:postgres 121.196.217.176:5000/gateway/gateway-backend:rc-1.0 +#Args : BUILD_DATE - build date +# VERSION - gateway version info +#Author : invan +#Email : nan.yin@nbltrust.com +################################################################### + +VERSION_FILE='package.json' +VERSION=V$(jq -r '.version' $VERSION_FILE) +echo -e "start to build image cybex-config-server:${VERSION}" + +echo -e "1 remove exist image and container" +docker stop cybex-config-server +docker rm cybex-config-server +docker rmi cybex-config-server:${VERSION} + +echo -e "2 build executable files" +echo `pwd` +git pull + +echo -e "3 build docker image" +docker build --force-rm --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VERSION=$VERSION -t cybex-config-server:$VERSION -f ./Dockerfile . + +echo -e "---------------------------" +echo -e "build cybex-config-server success" +echo -e "---------------------------"