clustered/setup/ubuntu.sh
#!/bin/bash

# Update package list and install prerequisites
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

# Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# Add Docker repository to APT sources
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Update package list again with new Docker repository
sudo apt update

# Install Docker Engine and Docker CLI
sudo apt install -y docker-ce docker-ce-cli containerd.io

# Start Docker and enable it to start at boot
sudo systemctl enable docker
sudo systemctl start docker

# Add the current user to the Docker group
sudo groupadd docker
sudo usermod -aG docker $USER

# Docker Compose installation (version 2.x as a Docker plugin)
DOCKER_COMPOSE_VERSION="2.27.0"
sudo curl -SL "https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# Verify installations
docker --version
docker-compose --version

echo "Installation completed! Log out and log back in for Docker group changes to take effect."

