Deploy Your Web Apps in Just a Minute - Made With ๐Ÿ’– for Dockerists

As a software engineer or a DevOps engineer, you may come up with boring tasks frequently, one of which is setting up a new cloud environment for deployment of your awesome web apps/micro services.
Using the following script, you will lose the dull pain. Just grab the script and run it with bash, then you will get the complete environment with docker/docker-compose and nginx which are all on the latest stable version.


Note: This is just for Ubuntu Bionic/Focal. Buzz me anytime in case you want to get the same one for any other distro, I'd love to help!



 1#!/bin/bash
 2# upgrades operating system
 3sudo apt-get update && sudo apt-get upgrade -y
 4
 5# install docker latest
 6sudo apt remove docker docker-engine docker.io containerd runc  # purging the legacy version if exists
 7sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
 8sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 9sudo apt-key fingerprint 0EBFCD88
10sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
11sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io -y
12# install docker-compose latest
13# curl -SL https://github.com/docker/compose/releases/download/v2.1.1/docker-compose-linux-x86_64 -o docker-compose
14curl -s https://api.github.com/repos/docker/compose/releases/latest \
15| grep -v ".sha256" \
16| grep browser_download_url \
17| grep "docker-compose-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m)" \
18| cut -d '"' -f 4 \
19| xargs curl -L -o docker-compose
20chmod +x docker-compose
21sudo mkdir -p /usr/local/lib/docker/cli-plugins
22sudo mv docker-compose /usr/local/lib/docker/cli-plugins
23# add the current non-root user to docker group
24sudo groupadd -f docker
25sudo usermod -aG docker $USER
26sudo docker -v
27sudo docker compose version
28
29# install nginx latest
30echo "
31deb [arch=amd64] http://nginx.org/packages/mainline/ubuntu/ bionic nginx
32deb-src http://nginx.org/packages/mainline/ubuntu/ bionic nginx
33" | sudo tee /etc/apt/sources.list.d/nginx.list
34wget http://nginx.org/keys/nginx_signing.key
35sudo apt-key add nginx_signing.key
36sudo apt update
37sudo apt remove nginx nginx-common nginx-full nginx-core -y
38sudo apt install nginx -y
39rm *.sh *.key
40
41echo -e "\e[32mPlease reboot your machine .. \e[0m"

You can also get the latest version of this script from my gist anytime.
Happy containerizing gents! ๐Ÿ˜Ž

comments powered by Disqus