Skip to content

Instantly share code, notes, and snippets.

@michaeldimoudis
Last active May 15, 2021 15:24
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 michaeldimoudis/2d2fb67386ffa18fe4e6ce364a0556c1 to your computer and use it in GitHub Desktop.
Save michaeldimoudis/2d2fb67386ffa18fe4e6ce364a0556c1 to your computer and use it in GitHub Desktop.
Post install script for Alpine docker images
#!/usr/bin/env sh
# Acknowledgement:
# Most of this file was derived from https://github.com/ironPeakServices/iron-alpine/blob/master/post-install.sh
# fail if a command fails
set -e
set -o pipefail
# remove apk package manager
find / -type f -iname '*apk*' -xdev -delete
find / -type d -iname '*apk*' -print0 -xdev | xargs -0 rm -r --
# set rx to all directories
find "$APP_DIR" -type d -exec chmod 500 {} +
if [ -z "$1" ]
then
# set r to all files
find "$APP_DIR" -type f -exec chmod 400 {} +
else
# set r to all files excluding executable binary
find "$APP_DIR" ! -name $1 -type f -exec chmod 400 {} +
fi
# remove chown/chmod after use (links & binaries)
find / \( -type f -o -type l \) -iname 'chown' -iname 'chmod' -xdev -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment