Refactor pipeline script
This commit is contained in:
parent
963cb1ed27
commit
be6c34cb53
2 changed files with 108 additions and 126 deletions
|
|
@ -1,18 +1,17 @@
|
||||||
|
---
|
||||||
|
# kind: pipeline
|
||||||
|
# type: docker
|
||||||
|
# name: default
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
build:
|
- name: build
|
||||||
when:
|
|
||||||
- branch: master
|
|
||||||
event: push
|
|
||||||
image: node:22
|
image: node:22
|
||||||
commands:
|
commands:
|
||||||
- npm ci
|
- npm ci
|
||||||
- npm run build
|
- npm run build
|
||||||
- echo "VERSION=$(cat version.txt)" > .env
|
- echo "VERSION=$(cat version.txt)" > .env
|
||||||
|
|
||||||
clear-from-host:
|
- name: clear-from-host
|
||||||
when:
|
|
||||||
- branch: master
|
|
||||||
event: push
|
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
|
|
@ -23,13 +22,12 @@ steps:
|
||||||
from_secret: ssh_key
|
from_secret: ssh_key
|
||||||
port: 2332
|
port: 2332
|
||||||
script:
|
script:
|
||||||
- rm -rf /home/mnisyif/docker-containers/mnisyif/frontend/*
|
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
||||||
- echo "Target directory cleared"
|
- rm -rf data index-*.js index-*.css logos papers pp projects
|
||||||
|
- find . -maxdepth 1 -type f -delete
|
||||||
|
- echo "Target directory cleared, resumes folder preserved"
|
||||||
|
|
||||||
copy-to-host:
|
- name: copy-to-host
|
||||||
when:
|
|
||||||
- branch: master
|
|
||||||
event: push
|
|
||||||
image: appleboy/drone-scp
|
image: appleboy/drone-scp
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
|
|
@ -45,10 +43,7 @@ steps:
|
||||||
- nginx.conf
|
- nginx.conf
|
||||||
- version.txt
|
- version.txt
|
||||||
|
|
||||||
webserver-deploy:
|
- name: webserver-deploy
|
||||||
when:
|
|
||||||
- branch: master
|
|
||||||
event: push
|
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
|
|
@ -61,26 +56,16 @@ steps:
|
||||||
script:
|
script:
|
||||||
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
||||||
- VERSION=$(cat version.txt)
|
- VERSION=$(cat version.txt)
|
||||||
- echo "Nginx configuration:"
|
- docker stop frontend-$VERSION || true
|
||||||
- cat nginx.conf
|
- docker rm frontend-$VERSION || true
|
||||||
- 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
|
docker run -d --name frontend-$VERSION -p 5173:80
|
||||||
-v /home/mnisyif/docker-containers/mnisyif/frontend/dist:/usr/share/nginx/html:ro
|
--mount type=bind,source=$PWD,target=/usr/share/nginx/html,readonly
|
||||||
-v /home/mnisyif/docker-containers/mnisyif/frontend/nginx.conf:/etc/nginx/nginx.conf:ro
|
-v $PWD/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"
|
- echo "Deployment completed"
|
||||||
confirm-deployment:
|
|
||||||
when:
|
- name: confirm-deployment
|
||||||
- branch: master
|
|
||||||
event: push
|
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
|
|
@ -91,23 +76,16 @@ steps:
|
||||||
from_secret: ssh_key
|
from_secret: ssh_key
|
||||||
port: 2332
|
port: 2332
|
||||||
script:
|
script:
|
||||||
- echo "Verifying deployment..."
|
- VERSION=$(cat /home/mnisyif/docker-containers/mnisyif/frontend/version.txt)
|
||||||
# Verify the container is running
|
- docker ps | grep frontend-$VERSION || { echo "Container failed to start"; exit 1; }
|
||||||
- docker ps | grep frontend || { echo "Container failed to start"; exit 1; }
|
- docker logs frontend-$VERSION
|
||||||
# Display container logs and test nginx configuration
|
- docker exec frontend-$VERSION nginx -t
|
||||||
- docker logs frontend
|
- docker exec frontend-$VERSION ls -la /usr/share/nginx/html
|
||||||
- docker exec frontend nginx -t
|
- docker exec frontend-$VERSION ls -la /usr/share/nginx/html/resumes
|
||||||
- docker exec frontend ps aux | grep nginx
|
|
||||||
|
|
||||||
# Check contents of /usr/share/nginx/html in the container
|
|
||||||
- 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; }
|
- curl -I http://localhost:5173 || { echo "HTTP request failed"; exit 1; }
|
||||||
- echo "Deployment confirmed successfully"
|
- echo "Deployment confirmed successfully"
|
||||||
cleanup:
|
|
||||||
when:
|
- name: cleanup
|
||||||
- branch: master
|
|
||||||
event: push
|
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
|
|
@ -119,11 +97,15 @@ steps:
|
||||||
port: 2332
|
port: 2332
|
||||||
script:
|
script:
|
||||||
- echo "Performing cleanup..."
|
- echo "Performing cleanup..."
|
||||||
# Clean up unused containers, images, and volumes
|
|
||||||
- docker system prune -f --volumes
|
- docker system prune -f --volumes
|
||||||
# Remove older versions of the Docker image
|
|
||||||
- >
|
- >
|
||||||
for img in $(docker images frontend --format "{{.Tag}}" | grep -v $(cat /home/mnisyif/docker-containers/mnisyif/frontend/version.txt)); 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 "Cleanup completed"
|
- echo "Cleanup completed"
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import styles from "./ResumeDownloader.module.css";
|
import styles from "./ResumeDownloader.module.css";
|
||||||
|
|
||||||
const ResumeDownload = ({ resumeLink }) => {
|
const ResumeDownloader = ({ resumeLink }) => {
|
||||||
const handleDownload = (e) => {
|
const handleDownload = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
|
@ -24,4 +24,4 @@ const ResumeDownload = ({ resumeLink }) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ResumeDownload;
|
export default ResumeDownloader;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue