Skip to content

Feature: adding hook to execute additional scripts on startup #31

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 7 commits into from

Conversation

williamsbdev
Copy link

This will close both #18 and #24.

The scripts are located in the /docker-entrypoint-initdb.d directory.

Paired on this with @benkiefer

@yosifkit
Copy link
Member

yosifkit commented Dec 3, 2014

We will just need to document the limitations of --init-file in the docs

@yosifkit
Copy link
Member

yosifkit commented Dec 3, 2014

LGTM

@williamsbdev
Copy link
Author

We added the docs in this PR.

@williamsbdev
Copy link
Author

One more thing, we also added the directory creation to the docker file.

@md5
Copy link

md5 commented Dec 3, 2014

Doesn't this break if there are no files in $INITDB_DIR with an error like cat: /docker-entrypoint-initdb.d/*.sql: No such file or directory?

@yosifkit
Copy link
Member

yosifkit commented Dec 3, 2014

@md5 is correct, we could just add a if [ -f "$f" ]; then

@williamsbdev
Copy link
Author

@md5 @yosifkit @benkiefer Fixed. Thanks for the catch!

@benkiefer
Copy link

Just checking to see if this was ready to merge. If there is anything else you need let us know.

@tianon
Copy link
Member

tianon commented Dec 17, 2014

The indentation here seems off. Is it using space instead of tabs?

Also, I'm not 100% comfortable with this unless we have some solid documentation for what the exact limitations are. People are inevitably going to run into issues with it, and then come asking why their huge mysqldump file doesn't work properly as-is, since there won't be much in the way of helpful output when it doesn't work.

I think a better stepping stone would be to emulate exactly what Postgres is doing for now, and improve there first. Here's something I've been playing with to implement over there:

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 -E < "$f" ;;
        esac
done

@apolci
Copy link

apolci commented Dec 18, 2014

@tianon I just run into one of such limitations (line length limit) with a dump and the effect is that the the DB was initialized and the container was runnging but some tables were missing so it took a while to figure out what was the problem.

@benkiefer
Copy link

Can you post your setup so that we can see what you are doing? It sounds like you are doing a dump on container startup?

@apolci
Copy link

apolci commented Dec 19, 2014

@benkiefer sorry, I wasn't clear. I just want to confirm the @tianon statement that people will run into issue with this implementation as I did.

My problem was that I was trying to import during the container startup a previously generated dump. Unfortunately the dump contained a pretty long statement (90,000 characters) and the mysql init file is limited to 20,000 characters (http://bugs.mysql.com/bug.php?id=67345 and they won't fix it).
This limit is only for init file run during mysqld startup. The mysql client instead can handle the dump just fine. If the user don't know the difference between running a script with the client and using it as init script for the daemon won't understand easily why the container doesn't initialize properly.

@jgangemi
Copy link

is there any movement on this? i could really use the functionality this will provide.

@yosifkit
Copy link
Member

I think @tianon was working on a set closer to what we have in the postgres image (to include bash scripts as well as sql), but this will still be very limited and needs documentation to cover the caveats.

@jgangemi
Copy link

is there another issue tracking this since you closed this one?

as a work around for anyone else, you could copy the entrypoint script that the container uses and append your init script contents to the end. if you're using mysqldump to create the file, be sure to use --extended-insert=FALSE and --skip-comments

@williamsbdev
Copy link
Author

There is not another issue. I was working through the comments but no
progress was made after I addressed the issues they had. I'm leaving it up
to someone else to do this if it is needed and will continue to just use my
fork.

On Saturday, January 24, 2015, Jae Gangemi notifications@github.com wrote:

is there another issue tracking this since you closed this one?

as a work around for anyone else, you could copy the entrypoint script
that the container uses and append your init script contents to the end. if
you're using mysqldump to create the file, be sure to use
--extended-insert=FALSE and --skip-comments


Reply to this email directly or view it on GitHub
#31 (comment).

Sent from Gmail Mobile

@jgangemi
Copy link

then shouldn't it be enough to provide a link to the mysql docs for the --init-file option in the docs here and also include my comment above about the options to use for mysqldump?

if that's what it takes to get this into the official build, i'd be happy to create a pull request. if there's something else, please let me know and i can look to address it. having this as part of the official image would be extremely helpful to me (and i'm sure others).

@williamsbdev
Copy link
Author

Go ahead and try that. LGTM. I gave up as I felt they wanted me to research
how the Postgres was working and change my implementation. I have it
working for myself felt it was sufficient to be merged.

On Saturday, January 24, 2015, Jae Gangemi notifications@github.com wrote:

then shouldn't it be enough to provide a link to the mysql docs for the
--init-file option in the docs here and also include my comment above
about the options to use for mysqldump?

if that's what it takes to get this into the official build, i'd be happy
to create a pull request. if there's something else, please let me know and
i can look to address it. having this as part of the official image would
be extremely helpful to me (and i'm sure others).


Reply to this email directly or view it on GitHub
#31 (comment).

Sent from Gmail Mobile

pascallandau-ay added a commit to paslandau/coding-challenge-setup that referenced this pull request Apr 29, 2021
- remove the hirak/prestissimo plugin because its
  not required for composer v2
- add 'platform: linux/amd64' to the mysql container
  in the docker-compose file to fix issues with
  M1 Mac users
  - see docker-library/mysql#31
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.

7 participants