feat:添加ci

This commit is contained in:
xlx 2024-03-19 09:23:48 +08:00
parent 8b2d7cfe3e
commit f5af44bcb7
4 changed files with 48 additions and 4 deletions

View File

@ -1,12 +1,32 @@
stages:
- build
- package
- deploy
cache:
policy: pull
key: '$CI_COMMIT_REF_NAME'
paths:
- node_modules/
build:
image: registry.zhst.com/video-analysis/pnpm4
tags:
- linux
stage: build
script:
- cd /home
- ls
- git
- node
- chmod +x ./deploy/build.sh && ./deploy/build.sh
artifacts:
name: '${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}_${CI_JOB_NAME}_${CI_PIPELINE_ID}'
paths:
- ./app/public/*
package:
tags:
- linux_shell
stage: package
script:
- chmod +x ./deploy/package.sh && ./deploy/package.sh
dependencies:
- build

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM alpine:latest
ADD ./app/public/ /app/public/
CMD [ "sh", "-c", "while true; do echo zhst-web; sleep 1; done" ]

9
deploy/build.sh Executable file
View File

@ -0,0 +1,9 @@
pnpm install
pnpm run build:master
mkdir -p ./app/public/
mv ./dist/* ./app/public/
cat ./app/public/index.html | head -n 7

10
deploy/package.sh Normal file
View File

@ -0,0 +1,10 @@
#! /bin/bash
set -e
export DOCKER_CLI_EXPERIMENTAL=enabled
docker login registry.zhst.com -u zhst -p Zhst666\&
# docker build -t registry.zhst.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME//\//-}-${CI_PIPELINE_ID} -f Dockerfile .
# docker push registry.zhst.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME//\//-}-${CI_PIPELINE_ID}
docker buildx build --platform linux/arm64,linux/amd64 -t registry.zhst.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME//\//-}-${CI_PIPELINE_ID} -f Dockerfile . --push