Commit 8694e76b authored by lipengcheng 's avatar lipengcheng

feat: docker && gitlab-ci

parent d916f783
image: node:12.16.3-alpine
variables:
IMAGE_NAME: 'laihua-webh5'
IMAGE_NAME: 'mould-nuxt'
IMAGE_TAG: 'latest'
ROBOT_WEBHOOK_URL: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b314c032-b7e2-4781-b2fa-f0bd26b75ebd'
VIEW_URL: 'https://beta.laihua.com/mobile'
PIPELINES_URL: 'https://gitlab.ilaihua.com/laihua-web/laihua-webh5/pipelines'
PIPELINES_URL: 'https://gitlab.ilaihua.com/laihua-web/mould-nuxt/pipelines'
stages:
- stage-test
......
FROM node:12.16.3-alpine
# ENV NODE_ENV=development
# ENV HOST 0.0.0.0
ARG MODE=uat
ENV MODE ${MODE}
RUN mkdir -p /usr/src/code
WORKDIR /usr/src/code
COPY ./package*.json ./
COPY ./nuxt.config*.js ./
RUN yarn
COPY ./.nuxt ./.nuxt
COPY ./static ./static
COPY ./nuxt.config.js ./
COPY ./config ./config
EXPOSE 3020
CMD [ "yarn","uat:start" ]
# CMD yarn $MODE:start
# CMD [ "sh", "-c", "yarn", "${MODE}:start" ]
#!/bin/bash
#--------------------------------------------
# 远程登录部署服务器,拉取对应aws镜像,通过laihua_compose启动有更新的镜像
# author:pc
#--------------------------------------------
imageName=${1}
imageTag=${2}
ssh -tt -p 22 ubuntu@52.83.232.6 "bash -s $imageName $imageTag" <<-'EOF'
login_register_cmd=`aws ecr get-login --region cn-northwest-1 | sed 's/-e none/''/g'`
eval $login_register_cmd
docker pull 551975756714.dkr.ecr.cn-northwest-1.amazonaws.com.cn/${1}:${2}
cd /var/www/laihua_compose
sh ./build.sh --webh5-version ${2}
exit
EOF
#!/usr/bin/env bash
if [[ $1 == "on_success" ]];
then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b314c032-b7e2-4781-b2fa-f0bd26b75ebd' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "<font color=\"info\">平台H5测试环境更新</font>
> <font color=\"warning\">内容: '$2'</font>
> <font color=\"warning\">author: '$3'</font>
> <font color=\"comment\">分支: '$4'</font>
`etc..`
**[点击查看]('$5')**
**[pipelines]('$6')**"
}
}
'
elif [[ $1 == "on_failure" ]];
then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b314c032-b7e2-4781-b2fa-f0bd26b75ebd' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "平台H5测试环境打包失败!
> <font color=\"warning\">内容: '$2'</font>
> <font color=\"warning\">author: '$3'</font>
[点击查看]('$6')"
}
}'
fi
#!/usr/bin/env bash
#--------------------------------------------
# 通过trigger触发指定分支或者tag的最后一条pipeline重新构建
# https://gitlab.ilaihua.com/laihua-web/laihua-webh5/settings/ci_cd#js-pipeline-triggers
# author:pc
#--------------------------------------------
TRIGGER_TOKEN=a052b40faf7b9e5b53ef9122fef8b8
REF=develop
URI=https://gitlab.ilaihua.com/api/v4/projects/351/trigger/pipeline
curl -X POST \
-F token=${TRIGGER_TOKEN} \
-F ref=${REF} \
${URI}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment