diff --git a/.woodpecker.yml b/.woodpecker.yml index 31ae79e..72b8357 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,87 +1,119 @@ ---- -version: "3.8" +steps: + build: + image: node:22 + commands: + - npm ci + - npm run build + - echo "VERSION=$(cat version.txt)" > .env -services: - woodpecker-gitea: - container_name: woodpecker-gitea - image: gitea/gitea:${GITEA_VERSION:-1.14.5} - restart: unless-stopped - cpus: 0.5 - mem_limit: 512m - networks: - - woodpecker - environment: - - APP_NAME="Gitea" - - USER_UID=116 - - 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 + clear-from-host: + image: appleboy/drone-ssh + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_username + key: + from_secret: ssh_key + port: 2332 + script: + - rm -rf /home/mnisyif/docker-containers/mnisyif/frontend/* + - echo "Target directory cleared" - woodpecker-server: - image: woodpeckerci/woodpecker-server:latest - container_name: woodpecker-server - restart: unless-stopped - cpus: 0.5 - mem_limit: 512m - networks: - - woodpecker - environment: - - WOODPECKER_OPEN=true - - WOODPECKER_HOST=https://ci.nisyif.com - - WOODPECKER_AGENT_SECRET=${WOODPECKER_AGENT_SECRET} - - WOODPECKER_GITEA=true - - WOODPECKER_GITEA_URL=https://git.nisyif.com - - 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 + copy-to-host: + image: appleboy/drone-scp + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_username + key: + from_secret: ssh_key + port: 2332 + target: /home/mnisyif/docker-containers/mnisyif/frontend + source: + - dist/ + - nginx.conf + - version.txt - woodpecker-agent: - image: woodpeckerci/woodpecker-agent:latest - container_name: woodpecker-agent - command: agent - restart: unless-stopped - cpus: 0.5 - mem_limit: 512m - depends_on: - - woodpecker-server - networks: - - woodpecker - environment: - - WOODPECKER_SERVER=woodpecker-server:9000 - - WOODPECKER_AGENT_SECRET=${WOODPECKER_AGENT_SECRET} - volumes: - - /var/run/docker.sock:/var/run/docker.sock - logging: *default-logging + webserver-deploy: + image: appleboy/drone-ssh + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_username + key: + from_secret: ssh_key + port: 2332 + script: + - cd /home/mnisyif/docker-containers/mnisyif/frontend + - VERSION=$(cat version.txt) + - echo "Nginx configuration:" + - cat nginx.conf + - echo "Contents of dist directory:" + - ls -la dist + # 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" -networks: - woodpecker: - name: woodpecker-net + confirm-deployment: + image: appleboy/drone-ssh + settings: + 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 -x-logging: - &default-logging - driver: "json-file" - options: - max-size: "1m" - max-file: "1" - tag: "{{.Name}}" \ No newline at end of file + # Check contents of /usr/share/nginx/html in the container + - docker exec frontend ls -la /usr/share/nginx/html + # Perform a simple HTTP request to check if the server is responding + - curl -I http://localhost:5173 || { echo "HTTP request failed"; exit 1; } + - echo "Deployment confirmed successfully" + + cleanup: + 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 diff --git a/public/assets/data/Murtadha.pdf b/public/assets/Murtadha.pdf similarity index 100% rename from public/assets/data/Murtadha.pdf rename to public/assets/Murtadha.pdf diff --git a/public/assets/data/personalData.json b/public/assets/data/personalData.json index 3a657b2..028de83 100644 --- a/public/assets/data/personalData.json +++ b/public/assets/data/personalData.json @@ -9,8 +9,8 @@ "about_me": "I'm passionate about computers, technology, and sports. I love creating solutions that ease people's daily routines. My journey in the world of tech began at a young age, and ever since, I've been captivated by the endless possibilities it offers. Whether it's building innovative solutions, developing software, or diving deep into the latest tech trends, I find immense joy in it all.", "interests": ["Tech Enthusiast", "Problem Solver", "Sports Lover"], "socials": [{ "github": "https://git.nisyif.com/mnisyif" }, { "linkedin": "https://www.linkedin.com/in/mnisyif/" }, { "twitter": "https://x.com/mnisyif" }], - "resumelink": "/assets/resume.pdf", - "pp":"/assets/pp/abtme.png", - "heropp":"/assets/pp/pp.jpg" + "resumelink": "/assets/Murtadha.pdf", + "pp": "/assets/pp/abtme.png", + "heropp": "/assets/pp/pp.jpg" } ]