feat: add gitlab-ci.yml

This commit is contained in:
shizhendong
2021-06-21 12:24:55 +08:00
parent 5a02d866b8
commit 5bc18ba93a
2 changed files with 53 additions and 0 deletions

44
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,44 @@
stages:
- build_project
- build_image
cache:
key:
files:
- package.json
paths:
- node_modules
before_script:
- export CNUI_TAG=$(date +%Y%m%d%H%M%S)
build_project:
stage: build_project
script:
- echo "npm install ..."
- npm install --unsafe-perm
- echo "npm run build"
- npm run build
artifacts:
paths:
- dist
only:
- dev
tags:
- GN-XXG-Server
build_image:
stage: build_image
script:
- echo "docker build"
- sudo docker build -t dev_cn-ui:$CNUI_TAG .
- echo "docker tag"
- sudo docker tag dev_cn-ui:$CNUI_TAG 192.168.40.153:9080/cyber-narrator/dev_cn-ui:$CNUI_TAG
- echo "docker push"
- sudo docker push 192.168.40.153:9080/cyber-narrator/dev_cn-ui:$CNUI_TAG
when: on_success
only:
- dev
tags:
- GN-XXG-Server

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM nginx:latest
MAINTAINER shizhendong shizhendong@zdjizhi.com
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面
COPY dist/ /usr/share/nginx/html/
# nginx 配置 制作镜像时不做处理 容器可自己挂载配置文件
#COPY nginx.conf /etc/nginx/nginx.conf