Refactor code
This commit is contained in:
parent
8d292b4ff7
commit
813e5afdd2
1 changed files with 82 additions and 114 deletions
196
.woodpecker.yml
196
.woodpecker.yml
|
|
@ -1,119 +1,87 @@
|
||||||
steps:
|
---
|
||||||
build:
|
version: "3.8"
|
||||||
image: node:22
|
|
||||||
commands:
|
|
||||||
- npm ci
|
|
||||||
- npm run build
|
|
||||||
- echo "VERSION=$(cat version.txt)" > .env
|
|
||||||
|
|
||||||
clear-from-host:
|
services:
|
||||||
image: appleboy/drone-ssh
|
woodpecker-gitea:
|
||||||
settings:
|
container_name: woodpecker-gitea
|
||||||
host:
|
image: gitea/gitea:${GITEA_VERSION:-1.14.5}
|
||||||
from_secret: ssh_host
|
restart: unless-stopped
|
||||||
username:
|
cpus: 0.5
|
||||||
from_secret: ssh_username
|
mem_limit: 512m
|
||||||
key:
|
networks:
|
||||||
from_secret: ssh_key
|
- woodpecker
|
||||||
port: 2332
|
environment:
|
||||||
script:
|
- APP_NAME="Gitea"
|
||||||
- rm -rf /home/mnisyif/docker-containers/mnisyif/frontend/*
|
- USER_UID=116
|
||||||
- echo "Target directory cleared"
|
- USER_GID=126
|
||||||
|
- USER=git
|
||||||
|
- RUN_MODE=prod
|
||||||
|
- DOMAIN=git.nisyif.com
|
||||||
|
- SSH_DOMAIN=git.nisyif.com
|
||||||
|
- HTTP_PORT=3000
|
||||||
|
- ROOT_URL=https://git.nisyif.com
|
||||||
|
- SSH_PORT=2121
|
||||||
|
- SSH_LISTEN_PORT=22
|
||||||
|
- DB_TYPE=sqlite3
|
||||||
|
- GIT_SSL_NO_VERIFY=true
|
||||||
|
ports:
|
||||||
|
- "2121:22"
|
||||||
|
- "3000:3000"
|
||||||
|
volumes:
|
||||||
|
- /mnt/fam_storage/Home/Git/data/gitea:/data
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
logging: *default-logging
|
||||||
|
|
||||||
copy-to-host:
|
woodpecker-server:
|
||||||
image: appleboy/drone-scp
|
image: woodpeckerci/woodpecker-server:latest
|
||||||
settings:
|
container_name: woodpecker-server
|
||||||
host:
|
restart: unless-stopped
|
||||||
from_secret: ssh_host
|
cpus: 0.5
|
||||||
username:
|
mem_limit: 512m
|
||||||
from_secret: ssh_username
|
networks:
|
||||||
key:
|
- woodpecker
|
||||||
from_secret: ssh_key
|
environment:
|
||||||
port: 2332
|
- WOODPECKER_OPEN=true
|
||||||
target: /home/mnisyif/docker-containers/mnisyif/frontend
|
- WOODPECKER_HOST=https://ci.nisyif.com
|
||||||
source:
|
- WOODPECKER_AGENT_SECRET=${WOODPECKER_AGENT_SECRET}
|
||||||
- dist/
|
- WOODPECKER_GITEA=true
|
||||||
- nginx.conf
|
- WOODPECKER_GITEA_URL=https://git.nisyif.com
|
||||||
- version.txt
|
- WOODPECKER_GITEA_CLIENT=${WOODPECKER_GITEA_CLIENT}
|
||||||
|
- WOODPECKER_GITEA_SECRET=${WOODPECKER_GITEA_SECRET}
|
||||||
|
- WOODPECKER_GITEA_SKIP_VERIFY=true
|
||||||
|
volumes:
|
||||||
|
- /mnt/fam_storage/Home/Git/data/server:/var/lib/woodpecker
|
||||||
|
ports:
|
||||||
|
- 8050:8000
|
||||||
|
logging: *default-logging
|
||||||
|
|
||||||
webserver-deploy:
|
woodpecker-agent:
|
||||||
image: appleboy/drone-ssh
|
image: woodpeckerci/woodpecker-agent:latest
|
||||||
settings:
|
container_name: woodpecker-agent
|
||||||
host:
|
command: agent
|
||||||
from_secret: ssh_host
|
restart: unless-stopped
|
||||||
username:
|
cpus: 0.5
|
||||||
from_secret: ssh_username
|
mem_limit: 512m
|
||||||
key:
|
depends_on:
|
||||||
from_secret: ssh_key
|
- woodpecker-server
|
||||||
port: 2332
|
networks:
|
||||||
script:
|
- woodpecker
|
||||||
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
environment:
|
||||||
- VERSION=$(cat version.txt)
|
- WOODPECKER_SERVER=woodpecker-server:9000
|
||||||
- echo "Nginx configuration:"
|
- WOODPECKER_AGENT_SECRET=${WOODPECKER_AGENT_SECRET}
|
||||||
- cat nginx.conf
|
volumes:
|
||||||
- echo "Contents of dist directory:"
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- ls -la dist
|
logging: *default-logging
|
||||||
# Stop and remove the existing container if it exists
|
|
||||||
- docker stop frontend || true
|
|
||||||
- docker rm frontend || true
|
|
||||||
# Run the new container with the current version, mounting the files
|
|
||||||
- >
|
|
||||||
docker run -d --name frontend -p 5173:80
|
|
||||||
-v /home/mnisyif/docker-containers/mnisyif/frontend/dist:/usr/share/nginx/html:ro
|
|
||||||
-v /home/mnisyif/docker-containers/mnisyif/frontend/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
||||||
nginx:alpine
|
|
||||||
# Tag the running container with the version
|
|
||||||
- docker tag nginx:alpine frontend:$VERSION
|
|
||||||
- echo "Deployment completed"
|
|
||||||
|
|
||||||
confirm-deployment:
|
networks:
|
||||||
image: appleboy/drone-ssh
|
woodpecker:
|
||||||
settings:
|
name: woodpecker-net
|
||||||
host:
|
|
||||||
from_secret: ssh_host
|
|
||||||
username:
|
|
||||||
from_secret: ssh_username
|
|
||||||
key:
|
|
||||||
from_secret: ssh_key
|
|
||||||
port: 2332
|
|
||||||
script:
|
|
||||||
- echo "Verifying deployment..."
|
|
||||||
# Verify the container is running
|
|
||||||
- docker ps | grep frontend || { echo "Container failed to start"; exit 1; }
|
|
||||||
# Display container logs and test nginx configuration
|
|
||||||
- docker logs frontend
|
|
||||||
- docker exec frontend nginx -t
|
|
||||||
- docker exec frontend ps aux | grep nginx
|
|
||||||
|
|
||||||
# Check contents of /usr/share/nginx/html in the container
|
x-logging:
|
||||||
- docker exec frontend ls -la /usr/share/nginx/html
|
&default-logging
|
||||||
# Perform a simple HTTP request to check if the server is responding
|
driver: "json-file"
|
||||||
- curl -I http://localhost:5173 || { echo "HTTP request failed"; exit 1; }
|
options:
|
||||||
- echo "Deployment confirmed successfully"
|
max-size: "1m"
|
||||||
|
max-file: "1"
|
||||||
cleanup:
|
tag: "{{.Name}}"
|
||||||
image: appleboy/drone-ssh
|
|
||||||
settings:
|
|
||||||
host:
|
|
||||||
from_secret: ssh_host
|
|
||||||
username:
|
|
||||||
from_secret: ssh_username
|
|
||||||
key:
|
|
||||||
from_secret: ssh_key
|
|
||||||
port: 2332
|
|
||||||
script:
|
|
||||||
- echo "Performing cleanup..."
|
|
||||||
# Clean up unused containers, images, and volumes
|
|
||||||
- docker system prune -f --volumes
|
|
||||||
# Remove older versions of the Docker image
|
|
||||||
- >
|
|
||||||
for img in $(docker images frontend --format "{{.Tag}}" | grep -v $(cat /home/mnisyif/docker-containers/mnisyif/frontend/version.txt)); do
|
|
||||||
docker rmi frontend:$img || true;
|
|
||||||
done
|
|
||||||
- echo "Cleanup completed"
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- push
|
|
||||||
branch:
|
|
||||||
- master
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue