#!/bin/bash
#Nifty: Install latest docker community engine

curl -s https://nifty.sh/lib/universal/niftylib.sh > /tmp/lib.nifty.sh
. /tmp/lib.nifty.sh
rm -f /tmp/lib.nifty.sh

# Requirements
require_root
require_64bit
require_os centos7

ce "Updating system packages"
yum clean all
yum makecache fast
yum update -y

ce "Installing requirements"
yum install -y yum-utils device-mapper-persistent-data lvm2

ce "Adding docker repo"
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

ce "Installing docker"
yum install docker-ce docker-ce-cli containerd.io -y

ce "Installing 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

ce "Enabling and starting docker"
systemctl enable docker
systemctl start docker
