Skip to content

Commit

Permalink
[TASK] Add verbose error when docker entrypoint fails (#799)
Browse files Browse the repository at this point in the history
A common problem for macOS users running docker as non-root is that
omitting a '--user' option makes our entrypoint.sh script try to
on-the-fly create a matching user.

(See TYPO3BestPractices/tea#1490)

This patch adds a verbose error message to hint at the problem.
  • Loading branch information
garvinhicking authored Oct 23, 2024
1 parent d6a10bd commit a5ea871
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,23 @@ if [ "${MY_UID}" -eq "0" ]; then
fi

addgroup typo3 --gid=$GID;

if [ $? -ne 0 ]; then
echo "Error: Failed to add group 'typo3' inside docker container."
echo "This can happen if docker does not run as root. Please add the"
echo "argument '--user=\$(id -u):\$(id -g)' to your 'docker run...' call."
exit 1
fi

adduser -h $(pwd) -D -G typo3 --uid=$UID typo3;

if [ $? -ne 0 ]; then
echo "Error: Failed to add user 'typo3' inside docker container."
echo "This can happen if docker does not run as root. Please add the"
echo "argument '--user=\$(id -u):\$(id -g)' to your 'docker run...' call."
exit 1
fi

# su behaves inconsistently with -c followed by flags
# Workaround: run the entrypoint and commands as a standalone script
echo "#!/usr/bin/env sh" > /usr/local/bin/invocation.sh
Expand Down

0 comments on commit a5ea871

Please sign in to comment.