Skip to content

Instantly share code, notes, and snippets.

@0sc
Last active September 10, 2019 12:15
Show Gist options
  • Save 0sc/71975ba7e9c1a32d37c815e2e2806920 to your computer and use it in GitHub Desktop.
Save 0sc/71975ba7e9c1a32d37c815e2e2806920 to your computer and use it in GitHub Desktop.
Setup script for golang, docker and docker-compose on Amazon Linux AMI 2017.09.0 (HVM) on EC2
#!bin/sh
# Update installed packages and package cache
sudo yum update -y
# make sure in the home folder
cd ~/
# Golang installation
# specify go version to install
VERSION=go1.9.linux-amd64.tar.gz
# download the go archive for the specified version
sudo curl -O https://storage.googleapis.com/golang/$VERSION
# extract the downloaded archive into the /usr/local folder
sudo tar -C /usr/local -xzf $VERSION
# setup the default GOPATH workspace
mkdir -p ~/go/bin
# set necessary go env variables
cat > ./go-env.sh <<EOL
export GOPATH=~/go
export PATH=$PATH:/usr/local/go/bin:~/go/bin
EOL
chmod +x ./go-env.sh
sudo mv ./go-env.sh /etc/profile.d/
# install git for go get command
# Docker installation
# http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
# install docker
sudo yum install -y git docker
# download the docker compose binary
curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` > ./docker-compose
# mv docker-compose binary to usr/bin folder
sudo mv ./docker-compose /usr/bin/docker-compose
# make docker-compose binary executable
sudo chmod +x /usr/bin/docker-compose
# start the docker service
sudo service docker start
# add ec2-user to the docker group to lose the sudo command when using docker
sudo usermod -a -G docker ec2-user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment