Last active
August 7, 2019 15:06
-
-
Save shykes/7bf0704be14a0a9288d7dfe98617c208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
update() { | |
mkdir -p ~/bin | |
curl -L -o ~/bin/dev.sh https://gist.githubusercontent.com/shykes/7bf0704be14a0a9288d7dfe98617c208/raw/dev.sh | |
chmod +x ~/bin/dev.sh | |
} | |
build() { | |
# Install docker-buildx | |
if [ ! -x ~/bin/docker-buildx ]; then | |
mkdir -p ~/bin | |
curl -L -o ~/bin/docker-buildx https://github.com/docker/buildx/releases/download/v0.2.2/buildx-v0.2.2.linux-amd64 | |
chmod +x ~/bin/docker-buildx | |
fi | |
~/bin/docker-buildx build \ | |
--load \ | |
--build-arg user=$USER \ | |
--build-arg uid=$UID \ | |
--build-arg docker_guid="$(ls -Lln /var/run/docker.sock | tr -s ' ' | cut -d' ' -f4)" \ | |
-t dev - <<-'EOF' | |
from alpine | |
run apk update | |
# Various utilities | |
run apk add openssh | |
run apk add bash | |
run apk add bind-tools | |
run apk add curl | |
run apk add docker | |
run apk add g++ | |
run apk add gcc | |
run apk add git | |
run apk add git-perl | |
run apk add make | |
run apk add python | |
run apk add openssl-dev | |
run apk add vim | |
run apk add py-pip | |
run apk add file | |
run apk add groff | |
run apk add jq | |
run apk add man | |
run cd /tmp && git clone https://github.com/AGWA/git-crypt && cd git-crypt && make && make install | |
run apk add go | |
run apk add coreutils | |
run apk add python2-dev | |
run apk add python3-dev | |
run apk add tar | |
run apk add vim | |
run apk add rsync | |
run apk add less | |
# AWS | |
# To configure: `aws configure` | |
# To configure: `aws ecr get-login --no-include-email | bash -x` | |
# To configure: `aws eks update-kubeconfig --name <cluster_name>` | |
run pip install awscli | |
run curl --silent --location "https://github.com/weaveworks/eksctl/releases/download/latest_release/eksctl_$(uname -s)_amd64.tar.gz" | tar -C /usr/local/bin -zxv | |
# Google Cloud | |
run curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-248.0.0-linux-x86_64.tar.gz | tar -C /var -zxv | |
# Kubernetes | |
run curl -L -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl | |
run curl -L -o /usr/local/bin/kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 && chmod +x /usr/local/bin/kustomize | |
run apk add ruby | |
run apk add ruby-dev | |
run gem install bigdecimal --no-ri --no-rdoc | |
run gem install kubernetes-deploy --no-ri --no-rdoc | |
# Javascript stuff | |
run apk add npm | |
run npm config set unsafe-perm true | |
run npm install -g yarn | |
# Netlify | |
run npm install -g netlify-cli | |
# Docker compose | |
run apk add libffi-dev | |
run pip install docker-compose | |
# MySQL | |
run apk add mysql-client | |
# Terraform | |
run (cd /tmp && curl -L -O https://releases.hashicorp.com/terraform/0.12.3/terraform_0.12.3_linux_amd64.zip && unzip terraform_0.12.3_linux_amd64.zip && cp terraform /usr/local/bin/) | |
# AWS SAM | |
run pip install aws-sam-cli | |
# User setup | |
arg user=dev | |
arg uid=4242 | |
arg docker_guid=999 | |
run apk add shadow sudo | |
run echo '%wheel ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers | |
run useradd -G docker,wheel -m -s /bin/bash -u $uid $user | |
run groupmod -o -g $docker_guid docker | |
env user=$user | |
workdir /home/$user | |
user $user | |
cmd /bin/bash | |
EOF | |
} | |
run() { | |
docker run \ | |
--rm \ | |
--privileged -v /var/run/docker.sock:/var/run/docker.sock \ | |
-i -t \ | |
-v "$HOME":/home/$USER\ | |
-v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent \ | |
-v /tmp:/tmp \ | |
"$@" \ | |
dev | |
} | |
dev() { | |
build | |
run | |
} | |
case "$1" in | |
update) | |
update | |
;; | |
build) | |
build | |
;; | |
run) | |
run "$@" | |
;; | |
dev) | |
dev "$@" | |
;; | |
"") | |
dev "$@" | |
;; | |
*) | |
echo >&2 unsupported command: $1 | |
exit 1 | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment