Refactor pipeline script
This commit is contained in:
parent
963cb1ed27
commit
be6c34cb53
2 changed files with 108 additions and 126 deletions
230
.woodpecker.yml
230
.woodpecker.yml
|
|
@ -1,129 +1,111 @@
|
|||
---
|
||||
# kind: pipeline
|
||||
# type: docker
|
||||
# name: default
|
||||
|
||||
steps:
|
||||
build:
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
image: node:22
|
||||
commands:
|
||||
- npm ci
|
||||
- npm run build
|
||||
- echo "VERSION=$(cat version.txt)" > .env
|
||||
- name: build
|
||||
image: node:22
|
||||
commands:
|
||||
- npm ci
|
||||
- npm run build
|
||||
- echo "VERSION=$(cat version.txt)" > .env
|
||||
|
||||
clear-from-host:
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host:
|
||||
from_secret: ssh_host
|
||||
username:
|
||||
from_secret: ssh_username
|
||||
key:
|
||||
from_secret: ssh_key
|
||||
port: 2332
|
||||
script:
|
||||
- rm -rf /home/mnisyif/docker-containers/mnisyif/frontend/*
|
||||
- echo "Target directory cleared"
|
||||
- name: clear-from-host
|
||||
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
|
||||
- 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:
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
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/
|
||||
- nginx.conf
|
||||
- version.txt
|
||||
- name: 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/
|
||||
- nginx.conf
|
||||
- version.txt
|
||||
|
||||
webserver-deploy:
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
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)
|
||||
- echo "Nginx configuration:"
|
||||
- cat nginx.conf
|
||||
- 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
|
||||
-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
|
||||
nginx:alpine
|
||||
# Tag the running container with the version
|
||||
- docker tag nginx:alpine frontend:$VERSION
|
||||
- echo "Deployment completed"
|
||||
confirm-deployment:
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
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
|
||||
- docker ps | grep frontend || { echo "Container failed to start"; exit 1; }
|
||||
# Display container logs and test nginx configuration
|
||||
- docker logs frontend
|
||||
- docker exec frontend nginx -t
|
||||
- docker exec frontend ps aux | grep nginx
|
||||
- name: webserver-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)
|
||||
- docker stop frontend-$VERSION || true
|
||||
- docker rm frontend-$VERSION || true
|
||||
- >
|
||||
docker run -d --name frontend-$VERSION -p 5173:80
|
||||
--mount type=bind,source=$PWD,target=/usr/share/nginx/html,readonly
|
||||
-v $PWD/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
nginx:alpine
|
||||
- echo "Deployment completed"
|
||||
|
||||
# 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; }
|
||||
- echo "Deployment confirmed successfully"
|
||||
cleanup:
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
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
|
||||
- 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
|
||||
docker rmi frontend:$img || true;
|
||||
done
|
||||
- echo "Cleanup completed"
|
||||
- name: 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:
|
||||
- VERSION=$(cat /home/mnisyif/docker-containers/mnisyif/frontend/version.txt)
|
||||
- docker ps | grep frontend-$VERSION || { echo "Container failed to start"; exit 1; }
|
||||
- docker logs frontend-$VERSION
|
||||
- docker exec frontend-$VERSION nginx -t
|
||||
- docker exec frontend-$VERSION ls -la /usr/share/nginx/html
|
||||
- docker exec frontend-$VERSION ls -la /usr/share/nginx/html/resumes
|
||||
- curl -I http://localhost:5173 || { echo "HTTP request failed"; exit 1; }
|
||||
- echo "Deployment confirmed successfully"
|
||||
|
||||
- name: 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..."
|
||||
- docker system prune -f --volumes
|
||||
- >
|
||||
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;
|
||||
done
|
||||
- echo "Cleanup completed"
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
import styles from "./ResumeDownloader.module.css";
|
||||
|
||||
const ResumeDownload = ({ resumeLink }) => {
|
||||
const ResumeDownloader = ({ resumeLink }) => {
|
||||
const handleDownload = (e) => {
|
||||
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