Skip to content

Add custom initialization hooks during database initialization #87

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
wants to merge 1 commit into from
Closed

Conversation

marclennox
Copy link

No description provided.

@yosifkit
Copy link
Member

LGTM, pending replication to the other versions. Looks just like the one on postgres 👍, but the user can just use the socket connection (mysql --protocol=socket -uroot -ppass).

I think it would be useful to also allow .sql files in there and just do the mysql command for them. Otherwise, we will need to document that their scripts would need to use the user and password that they set (or root and its password), which are all available in the env.

This is a fix for #24.

Ping @ltangvald and @tianon

@tianon
Copy link
Member

tianon commented Jul 23, 2015

I agree, I think something like this would be somewhat more flexible (and is what I was considering for PostgreSQL, but then found out that --single isn't actually recommended):

        echo
        for f in /docker-entrypoint-initdb.d/*; do
            case "$f" in
                *.sh)  echo "$0: running $f"; . "$f" ;;
                *.sql) echo "$0: running $f"; gosu postgres postgres --single -jE < "$f" && echo ;;
                *)     echo "$0: ignoring $f" ;;
            esac
            echo
        done

@marclennox
Copy link
Author

I like the idea of supporting both sql and sh scripts for both pg and mysql. For now I've created a mysql image (https://registry.hub.docker.com/u/tenstartups/mysql/dockerfile/) that has my proposed change (which indeed I copied directly from the postgres image). Anyway, it works like a charm.

@tianon
Copy link
Member

tianon commented Jul 23, 2015

docker-library/postgres#75 is my attempt to bring the Postgres image into line with MySQL's init process (and finally axe the practice of using postgres --single which upstream discourages), also adding support for *.sql officially.

@ltangvald
Copy link
Collaborator

Looks good to me too. Should also be mentioned in the documentation, though.
Edit: Adding support for .sql as well would be better, though :)

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.

4 participants