Skip to content

Instantly share code, notes, and snippets.

@angeloevangelista
Created December 6, 2022 14:26
Show Gist options
  • Save angeloevangelista/3f6db5fec385d085b05f0b1023a467a0 to your computer and use it in GitHub Desktop.
Save angeloevangelista/3f6db5fec385d085b05f0b1023a467a0 to your computer and use it in GitHub Desktop.
#!/bin/bash
$AWS_ECR_ENDPOINT=""
echo "export AWS_DEFAULT_REGION=us-east-1" >> ~/.bashrc
source ~/.bashrc
# Docker installation
sudo whoami
sudo dnf check-update
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io -y
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
sudo usermod -aG docker $(whoami)
# AWS CLI installation
if !(command -v python3 >/dev/null 2>&1)
then
sudo dnf install python3 -y
fi
if !(command -v python3-pip >/dev/null 2>&1)
then
sudo dnf install python3-pip -y
fi
pip install awscli
if [ -f "/home/$(whoami)/.docker/config.json" ]
then
rm "/home/$(whoami)/.docker/config.json"
fi
aws ecr get-login-password \
--region $AWS_DEFAULT_REGION | docker login \
--username AWS \
--password-stdin $AWS_ECR_ENDPOINT
if !([ -f "/home/$(whoami)/.docker/config.json" ])
then
echo "Could not authenticate on ECR"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment