core-env/functions

89 lines
1.4 KiB
Plaintext

# Stuff to make Cloud OS / Container Linux
# less type-tastic
dh () {
docker run \
-e TERM \
-e HOME \
-v $HOME:$HOME \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-u $(id -u):$(id -g) \
--log-driver=none \
"$@"
}
irssi () {
id=$(docker ps -q -f name=irssi)
if [ -z "$id" ]; then
dh -d -it --name irssi irssi
fi
docker attach irssi
echo
}
alias dev_appserver.py="_dev_appserver"
_dev_appserver () {
appdir=$1; shift
docker run \
--rm \
-p 8080:8080 \
-p 8000:8000 \
-v $appdir:/app:ro \
google/cloud-sdk \
dev_appserver.py --host=0.0.0.0 --admin_host=0.0.0.0 /app "$@"
}
unalias gcloud 2>/dev/null
gcloud () {
docker run \
--rm \
-it \
--net=host \
-v $HOME/.config:/.config \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker:ro \
google/cloud-sdk gcloud "$@"
}
dbtl () {
dh \
--rm \
-it \
-w "$(pwd)" \
dirtbags/dbtl "$@"
}
backup () {
dh \
--rm \
google/cloud-sdk gsutil rsync \
-r \
-d \
-x 'tmp/|src/|go/|.ssh/authorized_keys|.viminfo' \
$HOME \
gs://neale-private/fozzie
echo
}
go () {
dh \
--rm \
-e GOPATH=$HOME/go \
-w "$(pwd)" \
golang:1.6 go "$@"
}
docker-compose () {
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd):$(pwd) \
--rm \
--workdir $(pwd) \
docker/compose:1.16.1 "$@"
}