-
-
Save jrruethe/0e8c4d041a3d12a60535a3d61c0e95bc to your computer and use it in GitHub Desktop.
Create bare Ruby docker image
This file contains hidden or 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 | |
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