Skip to content

Instantly share code, notes, and snippets.

@orion6dev
Last active March 25, 2024 19:23
Show Gist options
  • Select an option

  • Save orion6dev/5f80e92939e610a52fa902661ddd3378 to your computer and use it in GitHub Desktop.

Select an option

Save orion6dev/5f80e92939e610a52fa902661ddd3378 to your computer and use it in GitHub Desktop.
Prepare an Ubuntu server with docker and docker compose
#!/bin/bash
# Import the Microsoft repository key
wget -q "https://packages.microsoft.com/keys/microsoft.asc" -O- | sudo apt-key add -
# Register the Microsoft Ubuntu repository
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -s -c)-prod $(lsb_release -s -c) main" > /etc/apt/sources.list.d/microsoft.list'
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
export DEBIAN_FRONTEND=noninteractive
apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
apt install -y neovim
apt install -y docker.io
apt install -y docker-compose-plugin
apt install -y git
apt install age
# Install PowerShell
apt install -y powershell
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
mkdir -p /etc/systemd/system/docker.service.d
printf "[Service]\nLimitNOFILE=65536\n" | sudo tee /etc/systemd/system/docker.service.d/override.conf
sudo systemctl daemon-reload
sudo systemctl restart docker
curl -sfL https://get.k3s.io | sh -
mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
export KUBECONFIG=~/.kube/config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment