diff --git a/.woodpecker.yml b/.woodpecker.yml index 196f6e7..35db603 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,3 +1,7 @@ +# kind: pipeline +# type: docker +# name: frontend-deployment + pipeline: build: image: node:22 @@ -36,27 +40,37 @@ pipeline: - cd /home/mnisyif/docker-containers/mnisyif/frontend - VERSION=$(cat version.txt) # Build the Docker image (no dist or nginx.conf needed in image) - - docker build -t frontend:$VERSION . + - echo "Building Docker image..." + - docker build -t frontend:$VERSION . || { echo "Docker build failed"; exit 1; } + - echo "Docker image built successfully: frontend:$VERSION" # Stop and remove the existing container if it exists + - echo "Stopping existing Docker container..." - docker stop frontend || true + - echo "Removing existing Docker container..." - docker rm frontend || true # Run the new container with bind mounts for dist and nginx.conf + - echo "Running new Docker container..." - docker run -d --name frontend -p 5173:80 \ -v /home/mnisyif/docker-containers/mnisyif/frontend/dist:/usr/share/nginx/html \ -v /home/mnisyif/docker-containers/mnisyif/frontend/nginx.conf:/etc/nginx/nginx.conf \ - frontend:$VERSION + frontend:$VERSION || { echo "Docker run failed"; exit 1; } + - echo "Docker container is running" # Remove dangling images + - echo "Removing dangling images..." - docker image prune -f # Clean up unused containers, images, and volumes + - echo "Cleaning up Docker system..." - docker system prune -f --volumes # Remove older versions of the Docker image + - echo "Removing older Docker images..." - > for img in $(docker images frontend --format "{{.Tag}}" | grep -v $VERSION); do docker rmi frontend:$img; done + - echo "Deployment completed successfully" trigger: event: - push branch: - - master \ No newline at end of file + - master diff --git a/nginx.conf b/nginx.conf index b2503a1..e96a8f8 100644 --- a/nginx.conf +++ b/nginx.conf @@ -3,7 +3,7 @@ server { location / { root /usr/share/nginx/html; - index index.html; + # index index.html; try_files $uri $uri/ /index.html; } } \ No newline at end of file