Update React / Spring / MySQL example#99
Merged
aiordache merged 4 commits intodocker:masterfrom Mar 22, 2021
frgreiner:master
Merged
Update React / Spring / MySQL example#99aiordache merged 4 commits intodocker:masterfrom frgreiner:master
aiordache merged 4 commits intodocker:masterfrom
frgreiner:master
Conversation
Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
Contributor
|
Could you try adding a DB heathcheck like this: db:
...
healthcheck:
test: "mysqladmin ping -h \"127.0.0.1\" --silent"
interval: 3s
retries: 5and make the backend to wait for the DB to be healthy before connecting to it: backend:
....
depends_on:
db:
condition: service_healthyNot sure if this healthcheck is reliable but seemed to work for me. |
- a start_period of 30s + 15s (interval * retries) should be long enough for mysql to initialize Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
Contributor
Author
|
Nice! Thats a smooth way to solve the race condition. |
krusher336
pushed a commit
to Inteliself/awesome-compose
that referenced
this pull request
Apr 13, 2021
* Update README.md title from NodeJS to Spring Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Always restart spring backend service Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Also pass db-password secret to spring backend Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Add healthcheck to the mysql service - a start_period of 30s + 15s (interval * retries) should be long enough for mysql to initialize Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
krusher336
pushed a commit
to Inteliself/awesome-compose
that referenced
this pull request
May 2, 2021
* Update README.md title from NodeJS to Spring Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Always restart spring backend service Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Also pass db-password secret to spring backend Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Add healthcheck to the mysql service - a start_period of 30s + 15s (interval * retries) should be long enough for mysql to initialize Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
krusher336
pushed a commit
to Inteliself/awesome-compose
that referenced
this pull request
May 2, 2021
* Update README.md title from NodeJS to Spring Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Always restart spring backend service Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Also pass db-password secret to spring backend Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Add healthcheck to the mysql service - a start_period of 30s + 15s (interval * retries) should be long enough for mysql to initialize Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
krusher336
pushed a commit
to Inteliself/awesome-compose
that referenced
this pull request
May 3, 2021
* Update README.md title from NodeJS to Spring Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Always restart spring backend service Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Also pass db-password secret to spring backend Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Add healthcheck to the mysql service - a start_period of 30s + 15s (interval * retries) should be long enough for mysql to initialize Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
archii
pushed a commit
to archii/awesome-compose
that referenced
this pull request
Jul 22, 2021
* Update README.md title from NodeJS to Spring Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Always restart spring backend service Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Also pass db-password secret to spring backend Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com> * Add healthcheck to the mysql service - a start_period of 30s + 15s (interval * retries) should be long enough for mysql to initialize Signed-off-by: Friedrich Greiner <greinerfriedrich@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I would like to suggest the following improvements:
docker-compose up -dthe backend container fails to start as the mysql container is up and running but still initializing and not ready to accept connections. Thedepends_on: ...option doesn't work as expected if the mysql volume isn't initialized yet. By addingrestart: alwaysthe spring backend will restart until the connection to the database can be established. This leads to a lot of exception stacktraces printed to the container log (only when started the first time), but in my opinion thats better than not starting at all.password.txtfile without making any changes to the backend source files.