Skip to content

Instantly share code, notes, and snippets.

@rbwestmoreland
Last active December 10, 2017 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbwestmoreland/7a61a8d87f82fde770ccb5fa3609e912 to your computer and use it in GitHub Desktop.
Save rbwestmoreland/7a61a8d87f82fde770ccb5fa3609e912 to your computer and use it in GitHub Desktop.
Docker PI

SSH into the Raspberry Pi and run the following command:
bash <(curl -s https://gist.githubusercontent.com/rbwestmoreland/7a61a8d87f82fde770ccb5fa3609e912/raw/init.sh)

When prompted, provide you AWS IAM access key and secret key.
This IAM user requires the AmazonEC2ContainerRegistryReadOnly policy.

#!/bin/sh
echo ----------------------------------------
echo Updating boot script...
echo ----------------------------------------
sudo git -C /usr/bin/rbwestmoreland/ pull
sudo sh /usr/bin/rbwestmoreland/start.sh
version: "3"
services:
web:
image: alexellis2/visualizer-arm:latest
ports:
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
placement:
constraints: [node.role == manager]
networks:
- webnet
networks:
webnet:
#!/bin/sh
echo ----------------------------------------
echo Updating...
echo ----------------------------------------
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get autoremove
sudo apt-get autoclean
echo ----------------------------------------
echo Installing Shared Components...
echo ----------------------------------------
sudo apt-get -y install git
sudo apt-get -y install python-pip
sudo apt-get -y install samba
echo ----------------------------------------
echo Installing Docker...
echo ----------------------------------------
sudo sed -i 's|ID=raspbian|ID=debian|' /etc/os-release
sudo docker --version || curl -sSL https://get.docker.com | sh
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker pi
echo ----------------------------------------
echo Installing AWS CLI...
echo ----------------------------------------
pip install awscli --upgrade --user
aws --version || export PATH=$PATH:~/.local/bin
aws configure
echo ----------------------------------------
echo Configuring AWS Docker Repository...
echo ----------------------------------------
aws ecr get-login --no-include-email --region us-east-1 | sh
sudo docker run 757558210780.dkr.ecr.us-east-1.amazonaws.com/rbwestmoreland/helloworld:arm32v7
echo ----------------------------------------
echo Installing boot.sh...
echo ----------------------------------------
sudo rm -rf /usr/bin/rbwestmoreland
sudo git clone https://gist.github.com/7a61a8d87f82fde770ccb5fa3609e912.git /usr/bin/rbwestmoreland
sudo grep -q "/usr/bin/rbwestmoreland/boot.sh" /etc/rc.local || sudo sed -i -e '$i sh /usr/bin/rbwestmoreland/boot.sh\n' /etc/rc.local
echo ----------------------------------------
echo Complete!
echo ----------------------------------------
#!/bin/sh
echo ----------------------------------------
echo Starting Docker Containers...
echo ----------------------------------------
docker run 757558210780.dkr.ecr.us-east-1.amazonaws.com/rbwestmoreland/helloworld:arm32v7
docker stack deploy -c /usr/bin/rbwestmoreland/docker-compose-visualizer.yml visualizer
docker system prune -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment