Skip to content

Commit d6922b4

Browse files
committed
Enhance prod-deploy script to clean up containers, images, and build cache before rebuilding services
1 parent 19b17d4 commit d6922b4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

prod-deploy.sh

+12-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ for SERVICE in "${SERVICES[@]}"; do
1818

1919
cd "$BASE_DIR/$SERVICE"
2020

21-
# Down the container
22-
echo "Stopping $SERVICE containers..."
23-
docker compose --env-file .env.prod -f docker-compose.prod.yml down
21+
# Down the container and remove volumes
22+
echo "Stopping $SERVICE containers and cleaning up..."
23+
docker compose --env-file .env.prod -f docker-compose.prod.yml down -v
2424

25-
# Rebuild
25+
# Remove old images
26+
echo "Removing old images for $SERVICE..."
27+
docker image prune -f --filter "label=com.docker.compose.project=${PROJECT}"
28+
29+
# Clean build cache
30+
echo "Cleaning build cache..."
31+
docker builder prune -f
32+
33+
# Rebuild with no cache
2634
echo "Rebuilding $SERVICE..."
2735
docker compose --env-file .env.prod -f docker-compose.prod.yml build --no-cache
2836

0 commit comments

Comments
 (0)