Skip to content

Export docker_process_sql for availability in executed initdb bash #1117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

scop
Copy link

@scop scop commented Aug 21, 2023

This way, executed bash initdb scripts do not need to source the entrypoint script (nor hardcode its path) to be able to use the function.

Note that the export only works for executed bash scripts.

Not crucial by any means, but I think it'd be nice to have.

Could apply to < 16 entrypoints too, if this is seen desirable.

This way, executed bash initdb scripts do not need to source the
entrypoint script (nor hardcode its path) to be able to use the
function.

Note that the export only works for executed _bash_ scripts.
@scop scop force-pushed the feat/export-docker_process_sql branch from 23b3683 to 7a362b6 Compare August 21, 2023 09:20
@tianon
Copy link
Member

tianon commented Nov 29, 2023

👀

# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
# https://github.com/docker-library/postgres/pull/452
if [ -x "$f" ]; then
printf '%s: running %s\n' "$0" "$f"
"$f"
else
printf '%s: sourcing %s\n' "$0" "$f"
. "$f"
fi

(If you remove the excitability bit on your initdb scripts, they'll be sourced instead and have direct access.)

@tianon tianon closed this Dec 13, 2023
@scop
Copy link
Author

scop commented Dec 19, 2023

(If you remove the excitability bit on your initdb scripts, they'll be sourced instead and have direct access.)

I know, but the executability check is unreliable, and doing that causes other problems: #1108

A reliable workaround against that is to make all .sh scripts executable, which then leads to this issue. Could you reconsider reopening/applying this?

@tianon
Copy link
Member

tianon commented Dec 20, 2023

If you need to work around #1108 too, I'd suggest something like this:

if ! command -v docker_process_sql > /dev/null; then
	source /usr/local/bin/docker-entrypoint.sh
fi

...

(the script is officially intended to be sourced in this way, and that is the canonical supported path for doing so)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants