Skip to content

Instantly share code, notes, and snippets.

@bigdawggi
Created May 19, 2021 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigdawggi/8ef9c27673bfa7a34b73f886d2dcfe53 to your computer and use it in GitHub Desktop.
Save bigdawggi/8ef9c27673bfa7a34b73f886d2dcfe53 to your computer and use it in GitHub Desktop.
Docker for Composer and Yarn
#!/bin/bash
# Go to script location
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
# Specify our version of node to run
composerVer="1.6.5"
# This is a little magic that makes it possible to forward an SSH agent into docker
unameS="$(uname -s)"
case "${unameS}" in
Darwin*)
SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
;;
*)
esac
# Append any arguments passed to this script. We have to do this as a variable,
# as doing this as the last parameter to the docker run command didn't respect
# the arguments
cmd="composer $@"
docker run -it --rm \
-v $PWD:/usr/local/app \
-v ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK} \
-v ~/.ssh/known_hosts:/root/.ssh/known_hosts:delegated \
-e SSH_AUTH_SOCK=${SSH_AUTH_SOCK} \
-e HOST_USER=$(whoami) \
-e COMPOSER_MEMORY_LIMIT=-1 \
-w /usr/local/app \
composer:$composerVer \
$cmd
#!/bin/bash
# Go to script location
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
# Specify our version of node to run
nodeVer="14.1"
# This is a little magic that makes it possible to forward an SSH agent into docker
unameS="$(uname -s)"
case "${unameS}" in
Darwin*)
SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
;;
*)
esac
# Append any arguments passed to this script. We have to do this as a variable,
# as doing this as the last parameter to the docker run command didn't respect
# the arguments
cmd="yarn $@"
docker run -it --rm \
-v $PWD:/usr/local/app \
-v ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK} \
-v ~/.ssh/known_hosts:/root/.ssh/known_hosts:delegated \
-e SSH_AUTH_SOCK=${SSH_AUTH_SOCK} \
-e HOST_USER=$(whoami) \
-w /usr/local/app \
node:$nodeVer \
$cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment