Refactor pipeline steps
This commit is contained in:
parent
22aec27560
commit
c7056841a2
1 changed files with 51 additions and 45 deletions
|
|
@ -2,14 +2,14 @@
|
|||
# type: docker
|
||||
# name: frontend-deployment
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
pipeline:
|
||||
build:
|
||||
image: node:22
|
||||
commands:
|
||||
- npm ci
|
||||
- npm run build
|
||||
|
||||
- name: ssh-copy-to-host
|
||||
ssh-copy-to-host:
|
||||
image: appleboy/drone-scp
|
||||
settings:
|
||||
host:
|
||||
|
|
@ -26,7 +26,7 @@ steps:
|
|||
- nginx.conf
|
||||
- version.txt
|
||||
|
||||
- name: webserver-docker-deploy
|
||||
webserver-docker-deploy:
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host:
|
||||
|
|
@ -39,12 +39,18 @@ steps:
|
|||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue