From e69adeb013252c8ed6741a3b6a47f1f3cdf76b93 Mon Sep 17 00:00:00 2001 From: Murtadha Date: Fri, 19 Jul 2024 17:31:42 -0400 Subject: [PATCH] v0.11.1 Modify pipeline to add volums instead of moving files --- .woodpecker.yml | 115 ++++++++++++++++++++++++------------------------ version.txt | 2 +- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 1761996..196f6e7 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,63 +1,62 @@ -# kind: pipeline -# type: docker -# name: frontend-deployment - pipeline: - build: - image: node:22 - commands: - - npm ci - - npm run build + build: + image: node:22 + commands: + - npm ci + - npm run build - ssh-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/ - - Dockerfile - - nginx.conf - - version.txt + ssh-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/ + - Dockerfile + - nginx.conf + - version.txt - webserver-docker-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) - # Build the new Docker image with the current version tag - - docker build -t frontend:$VERSION . - # 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 - - docker run -d --name frontend -p 5173:80 frontend:$VERSION - # Remove dangling images - - docker image prune -f - # 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 $VERSION); do - docker rmi frontend:$img; - done + webserver-docker-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) + # Build the Docker image (no dist or nginx.conf needed in image) + - docker build -t frontend:$VERSION . + # Stop and remove the existing container if it exists + - docker stop frontend || true + - docker rm frontend || true + # Run the new container with bind mounts for dist and nginx.conf + - 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 + # Remove dangling images + - docker image prune -f + # 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 $VERSION); do + docker rmi frontend:$img; + done trigger: - event: - - push - branch: - - master + event: + - push + branch: + - master \ No newline at end of file diff --git a/version.txt b/version.txt index 142464b..027934e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.11.0 \ No newline at end of file +0.11.1 \ No newline at end of file