Skip to content

Instantly share code, notes, and snippets.

@sergio-fry
Created December 1, 2022 15:10
Show Gist options
  • Save sergio-fry/bff5b332d01c65b0bf9e5c81ece38daa to your computer and use it in GitHub Desktop.
Save sergio-fry/bff5b332d01c65b0bf9e5c81ece38daa to your computer and use it in GitHub Desktop.
#!/bin/bash
docker_dev_home=$HOME/.docker-dev
project_name=${PWD##*/}
image_name=`echo $project_name | tr '[:upper:]' '[:lower:]'`-dev
docker create --name $image_name-volumes -v "/usr/local/bundle" -v "/root/.gradle" busybox || true
if [ -f "Dockerfile.dev" ]
then
docker build -t $image_name -f Dockerfile.dev .
else
docker build -t $image_name .
fi
extra_args=$DOCKER_EXTRA_ARGS
if [ -f ".rbenv-vars" ]
then
extra_args="$extra_args --env-file .rbenv-vars"
fi
IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
count=`lsof -n -i -P | grep -i TCP | grep socat | grep 6000 | wc -l | awk '{print $1}'`;
if [ "$count" == 0 ]
then
socat TCP-LISTEN:6000,bind=${IP},reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" &
fi
docker-term-run $extra_args -e DOCKER_PROJECT_NAME=$project_name -e DISPLAY=$IP:0 --volumes-from $image_name-volumes $image_name $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment