Skip to content

Instantly share code, notes, and snippets.

@josephglanville
Created October 21, 2014 11:26
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save josephglanville/5a251002de7a4451210d to your computer and use it in GitHub Desktop.
Save josephglanville/5a251002de7a4451210d to your computer and use it in GitHub Desktop.
Create bare Ruby docker image
#!/bin/bash
TARGET=$1
mkdir -p $TARGET
files=$(
dpkg -L ruby | grep '/usr/bin/'
dpkg -L ruby1.9.1 | grep '/usr/bin/'
echo '/usr/lib/ruby'
)
tar cpf - $files | tar xpf - -C $TARGET
find_executable() {
find ${TARGET} -type f -a -perm +0100 -print0 \
| xargs -0 -n1 ldd 2>/dev/null \
| awk '{ print $(NF-1) }' | sort -u | egrep "^/"
}
find_so() {
find ${TARGET} -name \*.so -a -print0 \
| xargs -0 -n1 ldd 2>/dev/null \
| awk '{ print $(NF-1) }' | sort -u | egrep "^/"
}
nss() {
for nssdir in {/usr,}/lib {/usr,}/lib/x86_64-linux-gnu/{,libnss}; do
if [[ -d $nssdir ]]; then
find $nssdir -maxdepth 1 \( -type f -o -type l \) -name 'libnss*'
fi
done
if [[ -d /usr/lib/nss ]]; then
find /usr/lib/nss -maxdepth 1 \( -type f -o -type l \)
fi
}
{ # automatically find and copy needed libraries
find_executable
find_so
nss
} | sort | uniq | cpio -L -p -d -u ${v} ${TARGET}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment