Closed yifanzheng closed 8 months ago
npm install
deploy_env=gdev
echo -e ">> $(date --rfc-3339=s) begin build app"
./node_modules/@angular/cli/bin/ng build --configuration=$deploy_env
# generate dockerfile
echo -e ">> $(date --rfc-3339=s) begin generate dockerfile"
cat <<EOF > Dockerfile
## Copy and Setup
FROM nginx
LABEL authors="Star"
MAINTAINER DAE
RUN mkdir /ng-alain
WORKDIR /ng-alain
# Just copy the dist directory and nginx config file
COPY ./dist ./dist
COPY _nginx/${deploy_env}.conf /etc/nginx/conf.d/nginx.conf
RUN rm -rf /usr/share/nginx/html/*
COPY /dist /usr/share/nginx/html
CMD [ "nginx", "-g", "daemon off;"]
EOF
echo -e ">> $(date --rfc-3339=s) end generate dockerfile \n"
# build and push image: different environments cannot share images
docker_register= ${镜像仓库地址}
tag=`date "+%Y%m%d%H%M%S"`
export docker_image_name=$docker_register/${GROUP_NAME}/${PROJECT_NAME}-${deploy_env}:${tag}
echo $docker_image_name > docker_image
echo -e ">> $(date --rfc-3339=s) begin to build docker image: $docker_image_name"
docker build -t $docker_image_name .
echo -e ">> $(date --rfc-3339=s) begin to push image."
echo $password | docker login -u $username --password-stdin $docker_register
docker push $docker_image_name
echo -e ">> $(date --rfc-3339=s) end to build and push image. \n"
# End build and push docker image
Java