ci: add woodpecker pipeline, Dockerfile and deploy configs
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
Mirrors the oneos- project layout: multi-stage node:22 → nginx:alpine build, Woodpecker pipeline that tags images as <branch>-<pkg-version> and pushes to harbor.lnh2e.com/lingniu-v1/bi, and a swarm-style docker-compose for deployment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
FROM node:22-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
bi:
|
||||||
|
image: harbor.lnh2e.com/lingniu-v1/bi:main-0.0.0
|
||||||
|
ports:
|
||||||
|
- "8114:80"
|
||||||
|
deploy:
|
||||||
|
replicas: 1
|
||||||
|
restart_policy:
|
||||||
|
condition: on-failure
|
||||||
|
placement:
|
||||||
|
constraints: [node.role == manager]
|
||||||
|
labels:
|
||||||
|
- portainer.hide=false
|
||||||
|
- project=lingniu
|
||||||
17
nginx.conf
Normal file
17
nginx.conf
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location /bi/ {
|
||||||
|
alias /usr/share/nginx/html/;
|
||||||
|
try_files $uri $uri/ /bi/index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /bi/assets/ {
|
||||||
|
alias /usr/share/nginx/html/assets/;
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
}
|
||||||
62
woodpecker.yml
Normal file
62
woodpecker.yml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
steps:
|
||||||
|
- name: npm-build
|
||||||
|
image: node:22-alpine
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
- manual
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- main
|
||||||
|
commands: |
|
||||||
|
cd $CI_WORKSPACE
|
||||||
|
npm ci
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# 获取分支名
|
||||||
|
BRANCH_NAME=$(echo $CI_COMMIT_BRANCH | tr / -)
|
||||||
|
echo "Branch name: $BRANCH_NAME"
|
||||||
|
|
||||||
|
# 版本号: 分支名-package.json版本
|
||||||
|
PKG_VERSION=$(node -e "console.log(require('./package.json').version)")
|
||||||
|
PROJECT_VERSION="$BRANCH_NAME-$PKG_VERSION"
|
||||||
|
echo "Docker tag: $PROJECT_VERSION"
|
||||||
|
echo $PROJECT_VERSION > $CI_WORKSPACE/project_version.txt
|
||||||
|
|
||||||
|
- name: docker-build
|
||||||
|
image: docker:24.0.5-cli
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
- manual
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- main
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
commands: |
|
||||||
|
PROJECT_VERSION=$(cat $CI_WORKSPACE/project_version.txt)
|
||||||
|
MODULE_NAME=bi
|
||||||
|
|
||||||
|
echo "Building Docker image: $MODULE_NAME:$PROJECT_VERSION"
|
||||||
|
|
||||||
|
cd $CI_WORKSPACE
|
||||||
|
|
||||||
|
docker build -t harbor.lnh2e.com/lingniu-v1/$MODULE_NAME:$PROJECT_VERSION .
|
||||||
|
|
||||||
|
mkdir -p /root/.docker
|
||||||
|
cat > /root/.docker/config.json <<EOF
|
||||||
|
{
|
||||||
|
"auths": {
|
||||||
|
"harbor.lnh2e.com": {
|
||||||
|
"auth": "$(echo Y2ljZDpMbkBjaWNkMDE=)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
docker push harbor.lnh2e.com/lingniu-v1/$MODULE_NAME:$PROJECT_VERSION
|
||||||
Reference in New Issue
Block a user