From babd07dcc9180846ff0ccd95e1422664f10dfc03 Mon Sep 17 00:00:00 2001 From: Dennis Buchhorn Date: Mon, 18 Oct 2021 10:14:32 +0200 Subject: [PATCH] feat: create build script and change Dockerfile --- Dockerfile | 5 +++++ build_script | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 build_script diff --git a/Dockerfile b/Dockerfile index ba87a33..46a1f25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,11 @@ FROM debian:buster-slim +ARG PHP_APACHE_WWW_DATA_UID=33 +ARG PHP_APACHE_WWW_DATA_GID=33 +RUN groupmod -g $PHP_APACHE_WWW_DATA_GID www-data; \ + usermod -u $PHP_APACHE_WWW_DATA_UID -g $PHP_APACHE_WWW_DATA_GID www-data + # prevent Debian's PHP packages from being installed # https://github.com/docker-library/php/pull/542 RUN set -eux; \ diff --git a/build_script b/build_script new file mode 100755 index 0000000..5c36dea --- /dev/null +++ b/build_script @@ -0,0 +1,25 @@ +#!/bin/bash + +echo "####################################################################" +echo "# docker_php_apache_build_script #" +echo "# Dennis Buchhorn - bucde@b-eit.de #" +echo "####################################################################" +echo "# This script will build an 'php:7.4-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:7.4-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 + +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!"