Files
minio-webui/scripts/deploy.sh
T
paul 0d24b45b79 fix: Update deployment script to use modern docker compose command
- Replace deprecated docker-compose with docker compose
- Add package-lock.json files for backend and frontend
- Fix npm ci deployment errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-22 17:37:48 +02:00

213 lines
6.1 KiB
Bash
Executable File

#!/bin/bash
set -e
echo "======================================"
echo "MinIO WebUI Deployment Script"
echo "======================================"
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Check if running as root (not recommended)
if [ "$EUID" -eq 0 ]; then
echo -e "${YELLOW}Warning: Running as root is not recommended${NC}"
read -p "Continue anyway? (y/N): " CONTINUE_ROOT
if [[ ! "$CONTINUE_ROOT" =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Check prerequisites
check_command() {
if ! command -v $1 &> /dev/null; then
echo -e "${RED}Error: $1 is required but not installed.${NC}"
exit 1
fi
}
echo "Checking prerequisites..."
check_command docker
check_command mc
echo -e "${GREEN}✓ All prerequisites installed${NC}"
# Check .env file
if [ ! -f .env ]; then
echo -e "${RED}Error: .env file not found. Please run setup.sh first.${NC}"
exit 1
fi
# Deployment options
echo ""
echo "Deployment Options"
echo "=================="
echo "1. Quick deployment (docker compose)"
echo "2. Production deployment with SSL"
echo "3. Update existing deployment"
echo "4. Stop deployment"
echo ""
read -p "Select option (1-4): " DEPLOY_OPTION
case $DEPLOY_OPTION in
1)
echo ""
echo "Starting quick deployment..."
echo "============================"
# Build and start containers
docker compose build
docker compose up -d
echo ""
echo -e "${GREEN}✓ Deployment completed!${NC}"
echo ""
echo "Services:"
echo "- Frontend: http://localhost"
echo "- Backend API: http://localhost:3000"
echo ""
docker compose ps
;;
2)
echo ""
echo "Production Deployment with SSL"
echo "=============================="
# Check for SSL certificates
if [ ! -f ssl/cert.pem ] || [ ! -f ssl/key.pem ]; then
echo -e "${YELLOW}SSL certificates not found.${NC}"
echo "Options:"
echo "1. Use Let's Encrypt (recommended for production)"
echo "2. Use existing certificates"
echo "3. Generate self-signed certificate (development only)"
read -p "Select option (1-3): " SSL_OPTION
case $SSL_OPTION in
1)
read -p "Enter your domain name: " DOMAIN
read -p "Enter your email: " EMAIL
# Install certbot if not present
if ! command -v certbot &> /dev/null; then
echo "Installing certbot..."
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install certbot
else
sudo apt-get update
sudo apt-get install -y certbot
fi
fi
# Generate Let's Encrypt certificate
sudo certbot certonly --standalone \
-d $DOMAIN \
--non-interactive \
--agree-tos \
--email $EMAIL
# Copy certificates
sudo cp /etc/letsencrypt/live/$DOMAIN/fullchain.pem ssl/cert.pem
sudo cp /etc/letsencrypt/live/$DOMAIN/privkey.pem ssl/key.pem
sudo chown $(whoami):$(whoami) ssl/*.pem
;;
2)
read -p "Path to certificate file: " CERT_PATH
read -p "Path to private key file: " KEY_PATH
cp $CERT_PATH ssl/cert.pem
cp $KEY_PATH ssl/key.pem
;;
3)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout ssl/key.pem \
-out ssl/cert.pem \
-subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"
;;
esac
fi
# Build and start with proxy profile
echo "Building containers..."
docker compose build
echo "Starting services..."
docker compose --profile proxy up -d
echo ""
echo -e "${GREEN}✓ Production deployment completed!${NC}"
echo ""
echo "Services:"
echo "- HTTPS: https://localhost"
echo "- HTTP (redirects to HTTPS): http://localhost"
echo ""
docker compose ps
;;
3)
echo ""
echo "Updating deployment..."
echo "====================="
# Pull latest changes
read -p "Pull latest changes from git? (y/N): " PULL_GIT
if [[ "$PULL_GIT" =~ ^[Yy]$ ]]; then
git pull
fi
# Rebuild containers
echo "Rebuilding containers..."
docker compose build
# Restart services
echo "Restarting services..."
docker compose down
docker compose up -d
echo ""
echo -e "${GREEN}✓ Update completed!${NC}"
docker compose ps
;;
4)
echo ""
echo "Stopping deployment..."
echo "===================="
docker compose down
echo ""
echo -e "${GREEN}✓ Services stopped${NC}"
;;
*)
echo -e "${RED}Invalid option${NC}"
exit 1
;;
esac
# Show logs option
echo ""
read -p "View logs? (y/N): " VIEW_LOGS
if [[ "$VIEW_LOGS" =~ ^[Yy]$ ]]; then
echo ""
echo "Showing logs (Ctrl+C to exit)..."
echo "================================"
docker compose logs -f
fi
echo ""
echo "Deployment script completed!"
echo ""
echo "Useful commands:"
echo "- View logs: docker compose logs -f"
echo "- View specific service: docker compose logs -f backend"
echo "- Restart services: docker compose restart"
echo "- Stop services: docker compose down"
echo "- Remove everything: docker compose down -v"