#!/bin/bash set -e echo "Increase pid_max limit" echo "kernel.pid_max=4194304" >> /etc/sysctl.conf sysctl -p echo "Create 4G SWAP" fallocate -l 4G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile echo "/swapfile swap swap defaults 0 0" >> /etc/fstab echo "Install docker" apt-get update apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - apt-key fingerprint 0EBFCD88 add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" apt-get update apt-get install -y docker-ce docker-ce-cli containerd.io echo "Install docker-compose" curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose echo "Increase file descriptor limit" echo "root soft nofile 999999" >> /etc/security/limits.conf echo "root hard nofile 999999" >> /etc/security/limits.conf echo "session required pam_limits.so" >> /etc/pam.d/common-session echo "session required pam_limits.so" >> /etc/pam.d/common-session-noninteractive sed -i -E 's/\#DefaultLimitNOFILE\=/DefaultLimitNOFILE=999999/g' /etc/systemd/system.conf read -p "Do you want to reboot now (y/n)? " -n 1 -r echo # move to a new line (optional) if [[ $REPLY =~ ^[Yy]$ ]] then echo "Reboot" reboot fi