feat: Add CI/CD and deployment configuration
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
Add Woodpecker CI pipeline, Dockerfile, nginx config, and docker-compose for automated build and deployment. Co-Authored-By: Claude Opus 4.6 (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;"]
|
||||
17
docker-compose.yml
Normal file
17
docker-compose.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
oneos:
|
||||
image: harbor.lnh2e.com/lingniu-v1/oneos:main-0.0.0
|
||||
network_mode: host
|
||||
environment:
|
||||
NGINX_PORT: "80"
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
placement:
|
||||
constraints: [node.role == manager]
|
||||
labels:
|
||||
- portainer.hide=false
|
||||
- project=lingniu
|
||||
15
nginx.conf
Normal file
15
nginx.conf
Normal file
@@ -0,0 +1,15 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /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=oneos
|
||||
|
||||
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