#!/bin/bash
# 项目名称(镜像名称)
project_name='fohow_admin'
# 获取项目版本号
eval project_version=`jq .version ./config/version.json`
# 获取git提交id
#git_commit_id=`git log -1 --pretty=format:%h`
git_commit_id=`date +%s`
# 定义镜像标签
#images_tag="${project_version}-${git_commit_id}"

images_tag="latest"

# 仓库地址
images_hub='registry.cn-shenzhen.aliyuncs.com/fohow'

# 构建镜像
docker build --build-arg CI_COMMIT_TAG=${images_tag} -t ${images_hub}/${project_name}:${images_tag} .
# 登录仓库
#docker login ${images_hub}
# 上传镜像
docker push ${images_hub}/${project_name}:${images_tag}

# 镜像清理
docker rmi $(docker images -q -f dangling=true)

echo "${images_hub}/${project_name}:${images_tag}"

