You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

56 lines
1.9 KiB

#!/bin/bash
echo "####################################################################"
echo "# docker_php_apache build_script #"
echo "# Dennis Buchhorn - bucde@b-eit.de #"
echo "####################################################################"
echo "# This script will build an 'php:8.1.1-apache-buster' image with #"
echo "# customized uid and gid for 'www-data' user. #"
echo "# With this you can bind mount volumes to /var/www/html/* and have #"
echo "# the same permissions from the host (if uid and gid matches). #"
#echo "# #"
echo "####################################################################"
echo ""
PHP_APACHE_IMAGE_NAME="b-eit/php:8.1.1-apache-buster"
PHP_APACHE_WWW_DATA_UID=""
PHP_APACHE_WWW_DATA_GID=""
read -p "Enter uid for 'www-data' user: " PHP_APACHE_WWW_DATA_UID
read -p "Enter gid for 'www-data' user: " PHP_APACHE_WWW_DATA_GID
git submodule update --init --recursive
git clean -dfx
cp docker_library_php/8.1/buster/apache/* .
rm -f tmp
touch tmp
PATCH_APPLIED="false"
while IFS= read -r LINE; do
printf "%s\n" "$LINE"
if ! [[ $PATCH_APPLIED == "true" ]]; then
if [[ $LINE == *"FROM debian:"* ]]; then
printf "\n"
printf "ARG PHP_APACHE_WWW_DATA_UID=33\n"
printf "ARG PHP_APACHE_WWW_DATA_GID=33\n"
printf "RUN groupmod -g \$PHP_APACHE_WWW_DATA_GID www-data; \\"
printf "\n"
printf "\tusermod -u \$PHP_APACHE_WWW_DATA_UID -g \$PHP_APACHE_WWW_DATA_GID www-data\n"
PATCH_APPLIED="true"
fi
fi
done < "Dockerfile" > tmp
rm -f Dockerfile
mv tmp Dockerfile
docker build -t $PHP_APACHE_IMAGE_NAME --build-arg PHP_APACHE_WWW_DATA_UID=$PHP_APACHE_WWW_DATA_UID --build-arg PHP_APACHE_WWW_DATA_GID=$PHP_APACHE_WWW_DATA_GID .
echo "Done!"