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

  1. #!/bin/bash
  2. echo "####################################################################"
  3. echo "# docker_php_apache build_script #"
  4. echo "# Dennis Buchhorn - bucde@b-eit.de #"
  5. echo "####################################################################"
  6. echo "# This script will build an 'php:8.1.1-apache-buster' image with #"
  7. echo "# customized uid and gid for 'www-data' user. #"
  8. echo "# With this you can bind mount volumes to /var/www/html/* and have #"
  9. echo "# the same permissions from the host (if uid and gid matches). #"
  10. #echo "# #"
  11. echo "####################################################################"
  12. echo ""
  13. PHP_APACHE_IMAGE_NAME="b-eit/php:8.1.1-apache-buster"
  14. PHP_APACHE_WWW_DATA_UID=""
  15. PHP_APACHE_WWW_DATA_GID=""
  16. read -p "Enter uid for 'www-data' user: " PHP_APACHE_WWW_DATA_UID
  17. read -p "Enter gid for 'www-data' user: " PHP_APACHE_WWW_DATA_GID
  18. git submodule update --init --recursive
  19. git clean -dfx
  20. cp docker_library_php/8.1/bullseye/apache/* .
  21. rm -f tmp
  22. touch tmp
  23. PATCH_APPLIED="false"
  24. while IFS= read -r LINE; do
  25. printf "%s\n" "$LINE"
  26. if ! [[ $PATCH_APPLIED == "true" ]]; then
  27. if [[ $LINE == *"FROM debian:"* ]]; then
  28. printf "\n"
  29. printf "ARG PHP_APACHE_WWW_DATA_UID=33\n"
  30. printf "ARG PHP_APACHE_WWW_DATA_GID=33\n"
  31. printf "RUN groupmod -g \$PHP_APACHE_WWW_DATA_GID www-data; \\"
  32. printf "\n"
  33. printf "\tusermod -u \$PHP_APACHE_WWW_DATA_UID -g \$PHP_APACHE_WWW_DATA_GID www-data\n"
  34. PATCH_APPLIED="true"
  35. fi
  36. fi
  37. done < "Dockerfile" > tmp
  38. rm -f Dockerfile
  39. mv tmp Dockerfile
  40. 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 .
  41. echo "Done!"