diff --git a/.woodpecker.yml b/.woodpecker.yml index da62fde..469133d 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,33 +1,30 @@ --- -# kind: pipeline -# type: docker -# name: default steps: - - name: build - image: node:22 - commands: - - npm ci - - npm run build - - echo "VERSION=$(cat version.txt)" > .env + build: + image: node:22 + commands: + - npm ci + - npm run build + - echo "VERSION=$(cat version.txt)" > .env - - name: 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: - - cd /home/mnisyif/docker-containers/mnisyif/frontend - - rm -rf data index-*.js index-*.css logos papers pp projects - - find . -maxdepth 1 -type f -delete - - echo "Target directory cleared, resumes folder preserved" + 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: + - cd /home/mnisyif/docker-containers/mnisyif/frontend + - rm -rf data index-*.js index-*.css logos papers pp projects + - find . -maxdepth 1 -type f -delete + - echo "Target directory cleared, resumes folder preserved" - - name: copy-to-host + copy-to-host: image: appleboy/drone-scp settings: host: @@ -43,84 +40,84 @@ steps: - nginx.conf - version.txt - - name: 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" + 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" - - name: 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: - - cd /home/mnisyif/docker-containers/mnisyif/frontend - - VERSION=$(cat version.txt) - - echo "Confirming deployment for version: $VERSION" - - docker ps -a - - if ! docker ps | grep -q frontend-$VERSION; then - echo "Container failed to start"; - docker logs frontend-$VERSION; - exit 1; - fi - - echo "Container is running, checking Nginx configuration..." - - docker exec frontend-$VERSION nginx -t || { echo "Nginx configuration test failed"; exit 1; } - - echo "Listing contents of /usr/share/nginx/html" - - docker exec frontend-$VERSION ls -la /usr/share/nginx/html - - echo "Listing contents of /usr/share/nginx/html/resumes" - - docker exec frontend-$VERSION ls -la /usr/share/nginx/html/resumes || echo "Resumes directory not found" - - echo "Checking HTTP response..." - - curl -I http://localhost:5173 || { echo "HTTP request failed"; exit 1; } - - echo "Deployment confirmed successfully" + 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: + - cd /home/mnisyif/docker-containers/mnisyif/frontend + - VERSION=$(cat version.txt) + - echo "Confirming deployment for version: $VERSION" + - docker ps -a + - if ! docker ps | grep -q frontend-$VERSION; then + echo "Container failed to start"; + docker logs frontend-$VERSION; + exit 1; + fi + - echo "Container is running, checking Nginx configuration..." + - docker exec frontend-$VERSION nginx -t || { echo "Nginx configuration test failed"; exit 1; } + - echo "Listing contents of /usr/share/nginx/html" + - docker exec frontend-$VERSION ls -la /usr/share/nginx/html + - echo "Listing contents of /usr/share/nginx/html/resumes" + - docker exec frontend-$VERSION ls -la /usr/share/nginx/html/resumes || echo "Resumes directory not found" + - echo "Checking HTTP response..." + - curl -I http://localhost:5173 || { echo "HTTP request failed"; exit 1; } + - echo "Deployment confirmed successfully" - - name: 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..." - - docker system prune -f --volumes - - > - 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" + 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..." + - docker system prune -f --volumes + - > + 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: branch: