Separate deploy-webserver to multiple steps, for ease of readibility
This commit is contained in:
parent
7665166847
commit
935b81351c
1 changed files with 35 additions and 5 deletions
|
|
@ -62,8 +62,24 @@ pipeline:
|
||||||
-v /home/mnisyif/docker-containers/mnisyif/frontend/dist:/usr/share/nginx/html:ro
|
-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
|
-v /home/mnisyif/docker-containers/mnisyif/frontend/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
nginx:alpine
|
nginx:alpine
|
||||||
|
# Tag the running container with the version
|
||||||
|
- docker tag nginx:alpine frontend:$VERSION
|
||||||
|
- echo "Deployment completed"
|
||||||
|
|
||||||
|
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
|
# Verify the container is running
|
||||||
- docker ps | grep frontend || echo "Container failed to start"
|
- docker ps | grep frontend || { echo "Container failed to start"; exit 1; }
|
||||||
# Display container logs
|
# Display container logs
|
||||||
- docker logs frontend
|
- docker logs frontend
|
||||||
# Test Nginx configuration
|
# Test Nginx configuration
|
||||||
|
|
@ -72,16 +88,30 @@ pipeline:
|
||||||
- docker exec frontend ps aux | grep nginx
|
- docker exec frontend ps aux | grep nginx
|
||||||
# Check contents of /usr/share/nginx/html in the container
|
# Check contents of /usr/share/nginx/html in the container
|
||||||
- docker exec frontend ls -la /usr/share/nginx/html
|
- 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
|
# Clean up unused containers, images, and volumes
|
||||||
- docker system prune -f --volumes
|
- docker system prune -f --volumes
|
||||||
# Tag the running container with the version
|
|
||||||
- docker tag nginx:alpine frontend:$VERSION
|
|
||||||
# Remove older versions of the Docker image
|
# Remove older versions of the Docker image
|
||||||
- >
|
- >
|
||||||
for img in $(docker images frontend --format "{{.Tag}}" | grep -v $VERSION); do
|
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;
|
docker rmi frontend:$img || true;
|
||||||
done
|
done
|
||||||
- echo "Deployment completed"
|
- echo "Cleanup completed"
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue