Used Claude to refactor pipeline code
This commit is contained in:
parent
04d5d286a1
commit
eeb659a3a6
1 changed files with 13 additions and 7 deletions
|
|
@ -33,7 +33,6 @@ pipeline:
|
||||||
target: /home/mnisyif/docker-containers/mnisyif/frontend
|
target: /home/mnisyif/docker-containers/mnisyif/frontend
|
||||||
source:
|
source:
|
||||||
- dist/
|
- dist/
|
||||||
- Dockerfile
|
|
||||||
- nginx.conf
|
- nginx.conf
|
||||||
- version.txt
|
- version.txt
|
||||||
|
|
||||||
|
|
@ -50,22 +49,29 @@ pipeline:
|
||||||
script:
|
script:
|
||||||
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
- cd /home/mnisyif/docker-containers/mnisyif/frontend
|
||||||
- VERSION=$(cat version.txt)
|
- VERSION=$(cat version.txt)
|
||||||
# Build the new Docker image with the current version tag
|
|
||||||
- docker build -t frontend:$VERSION . || { echo "Docker build failed"; exit 1; }
|
|
||||||
# Stop and remove the existing container if it exists
|
# Stop and remove the existing container if it exists
|
||||||
- docker stop frontend || true
|
- docker stop frontend || true
|
||||||
- docker rm frontend || true
|
- docker rm frontend || true
|
||||||
# Run the new container with the current version
|
# Run the new container with the current version, mounting the files
|
||||||
- docker run -d --name frontend -p 5173:80 frontend:$VERSION
|
- >
|
||||||
# Remove dangling images
|
docker run -d --name frontend -p 5173:80
|
||||||
- docker image prune -f
|
-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
|
||||||
|
# Verify the container is running
|
||||||
|
- docker ps | grep frontend || echo "Container failed to start"
|
||||||
|
# Display container logs
|
||||||
|
- docker logs frontend
|
||||||
# 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 $VERSION); do
|
||||||
docker rmi frontend:$img || true;
|
docker rmi frontend:$img || true;
|
||||||
done
|
done
|
||||||
|
- echo "Deployment completed"
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue