Last active
May 15, 2021 15:24
-
-
Save michaeldimoudis/2d2fb67386ffa18fe4e6ce364a0556c1 to your computer and use it in GitHub Desktop.
Post install script for Alpine docker images
This file contains 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
#!/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