Refactor pipeline script
This commit is contained in:
parent
c865f926b0
commit
2af2d81115
1 changed files with 18 additions and 15 deletions
|
|
@ -43,7 +43,7 @@ steps:
|
|||
- nginx.conf
|
||||
- version.txt
|
||||
|
||||
- name: build-and-deploy
|
||||
- name: deploy
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host:
|
||||
|
|
@ -55,20 +55,23 @@ steps:
|
|||
port: 2332
|
||||
script:
|
||||
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
||||
- VERSION=$(cat version.txt)
|
||||
- echo "Building and deploying version: $VERSION"
|
||||
- |
|
||||
cat << EOF > Dockerfile
|
||||
FROM nginx:alpine
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY dist /usr/share/nginx/html
|
||||
COPY resumes /usr/share/nginx/html/resumes
|
||||
EOF
|
||||
- docker build -t frontend:$VERSION .
|
||||
- docker stop frontend-$VERSION || true
|
||||
- docker rm frontend-$VERSION || true
|
||||
- docker run -d --name frontend-$VERSION -p 5173:80 frontend:$VERSION
|
||||
- echo "Deployment attempt completed"
|
||||
- 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"
|
||||
|
||||
- name: confirm-deployment
|
||||
image: appleboy/drone-ssh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue