Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apache-Dockerfile-block-2
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@

COPY docker-entrypoint.sh /docker-entrypoint.sh
COPY docker-entrypoint.d /docker-entrypoint.d

COPY apache2-foreground /usr/local/bin/
WORKDIR /var/www/html

EXPOSE 80
CMD ["apache2-foreground"]

ENTRYPOINT [ "/docker-entrypoint.sh" ]

CMD [ "apache2-foreground" ]
12 changes: 12 additions & 0 deletions docker-entrypoint.d/00-update-uid
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# current www-data UID
CURRENT_UID=`id -u www-data`
WANTED_UID=${RUN_AS_UID:-33}

# check if UID need to be updated
if [ $CURRENT_UID -ne $WANTED_UID ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using this same code in a different docker image to change the www-data UID and needed to tweak this line to if [ "$CURRENT_UID" -ne "$WANTED_UID" ]; then, and the above to WANTED_UID=${RUN_AS_UID}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CURRENT_UID and WANTED_UID should not be empty because :

  • id command always return numeric identifier
  • ${RUN_AS_UID:-33} use 33 as default value if RUN_AS_UID is not set

Can you explain steps to reproduce your issue, maybe your www-data default uid was not set to 33.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vampouille that makes sense.. I'm not clear why the ID was not set by default on my instance, but based on what you're saying it doesn't seem like this change needs to be made. Thanks for taking the time to respond!

echo "Updating www-data UID to $WANTED_UID"
usermod --non-unique --uid $WANTED_UID www-data
chown -R www-data /run/apache2 /run/lock/apache2 /var/cache/apache2/mod_cache_disk /var/log/apache2
fi
10 changes: 10 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

DIR=/docker-entrypoint.d

if [[ -d "$DIR" ]]
then
/bin/run-parts --verbose "$DIR"
fi

exec "$@"
3 changes: 3 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ for version in "${versions[@]}"; do
ia { ac++ }
ia && ac == 1 { system("cat '$variant'-Dockerfile-block-" ab) }
' "$base" > "$version/$target/Dockerfile"
if [ $target == "apache" ]; then
cp -vr docker-entrypoint.sh docker-entrypoint.d "$version/$target/"
fi
cp -v docker-php-ext-* "$version/$target/"
cp -v docker-php-source "$version/$target/"
dockerfiles+=( "$version/$target/Dockerfile" )
Expand Down