add files infra docker service for data platform
This commit is contained in:
111
setup-ubuntu.sh
Normal file
111
setup-ubuntu.sh
Normal file
@@ -0,0 +1,111 @@
|
||||
#!/bin/bash
|
||||
# Sriphat Data Platform - Ubuntu Server Setup Script
|
||||
# Run as root or with sudo
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Sriphat Data Platform - Ubuntu Server Setup ==="
|
||||
echo ""
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run as root or with sudo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update system
|
||||
echo "[1/6] Updating system packages..."
|
||||
apt-get update
|
||||
apt-get upgrade -y
|
||||
|
||||
# Install Docker
|
||||
echo "[2/6] Installing Docker..."
|
||||
if ! command -v docker &> /dev/null; then
|
||||
# Remove old versions
|
||||
apt-get remove -y docker docker-engine docker.io containerd runc 2>/dev/null || true
|
||||
|
||||
# Install dependencies
|
||||
apt-get install -y \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
lsb-release
|
||||
|
||||
# Add Docker's official GPG key
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||
|
||||
# Set up repository
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
|
||||
# Install Docker Engine
|
||||
apt-get update
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
|
||||
# Start and enable Docker
|
||||
systemctl start docker
|
||||
systemctl enable docker
|
||||
|
||||
echo "✓ Docker installed successfully"
|
||||
else
|
||||
echo "✓ Docker already installed"
|
||||
fi
|
||||
|
||||
# Install Docker Compose (standalone - backup)
|
||||
echo "[3/6] Installing Docker Compose standalone..."
|
||||
if ! command -v docker-compose &> /dev/null; then
|
||||
DOCKER_COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||
curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
chmod +x /usr/local/bin/docker-compose
|
||||
echo "✓ Docker Compose installed: $DOCKER_COMPOSE_VERSION"
|
||||
else
|
||||
echo "✓ Docker Compose already installed"
|
||||
fi
|
||||
|
||||
# Add current user to docker group (if not root)
|
||||
echo "[4/6] Configuring Docker permissions..."
|
||||
if [ -n "$SUDO_USER" ]; then
|
||||
usermod -aG docker $SUDO_USER
|
||||
echo "✓ Added $SUDO_USER to docker group (logout and login to apply)"
|
||||
fi
|
||||
|
||||
# Install additional tools
|
||||
echo "[5/6] Installing additional tools..."
|
||||
apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
wget \
|
||||
vim \
|
||||
htop \
|
||||
net-tools \
|
||||
ufw
|
||||
|
||||
# Configure firewall
|
||||
echo "[6/6] Configuring firewall..."
|
||||
ufw --force enable
|
||||
ufw allow 22/tcp # SSH
|
||||
ufw allow 80/tcp # HTTP
|
||||
ufw allow 443/tcp # HTTPS
|
||||
ufw allow 81/tcp # Nginx Proxy Manager Admin
|
||||
ufw allow 8080/tcp # Keycloak (optional - can be removed after Nginx setup)
|
||||
ufw status
|
||||
|
||||
echo ""
|
||||
echo "=== Setup Completed Successfully ==="
|
||||
echo ""
|
||||
echo "Docker version: $(docker --version)"
|
||||
echo "Docker Compose version: $(docker compose version)"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Logout and login again (to apply docker group permissions)"
|
||||
echo "2. Clone/copy the sriphat-dataplatform project"
|
||||
echo "3. Configure .env.global"
|
||||
echo "4. Run: bash start-all.sh"
|
||||
echo ""
|
||||
echo "Optional: Setup automatic backup"
|
||||
echo " sudo crontab -e"
|
||||
echo " Add: 0 2 * * * /opt/sriphat-dataplatform/backup-daily.sh"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user