Skip to content

Instantly share code, notes, and snippets.

@thelebster
Last active March 11, 2020 07:16
Show Gist options
  • Select an option

  • Save thelebster/7f66e1f3509f9b23b8f0921f0ea5a9f8 to your computer and use it in GitHub Desktop.

Select an option

Save thelebster/7f66e1f3509f9b23b8f0921f0ea5a9f8 to your computer and use it in GitHub Desktop.
DigitalOcean User Data: Install Ningx, Docker CE and add GitHub SSH key
#!/bin/bash
apt-get -y update
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
apt-get -y update
apt-cache policy docker-ce
apt-get -y install docker-ce
export DOCKER_STATUS=$(systemctl status docker)
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
export DOCKER_COMPOSE_VERSION=$(docker-compose --version)
apt-get -y install nginx
apt-get -y install mc
apt-get -y install git
tee -a ~/.ssh/config > /dev/null << END
Host github.com
HostName github.com
IdentityFile ~/.ssh/github
User git
END
tee -a ~/.ssh/github > /dev/null << END
-----BEGIN OPENSSH PRIVATE KEY-----
...
..
.
-----END OPENSSH PRIVATE KEY-----
END
chmod 400 ~/.ssh/github
ssh-keyscan github.com >> ~/.ssh/known_hosts
echo "docker status: $DOCKER_STATUS, docker-compose version: $DOCKER_COMPOSE_VERSION" > /var/www/html/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment