Skip to content
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

upgrade #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

upgrade #3

wants to merge 1 commit into from

Conversation

gogobook
Copy link

upgrade

@@ -13,5 +13,5 @@ services:
depends_on:
- postgres_db
- mongo_db
entrypoint: /app/docker/web/entrypoint.sh
privileged: true
command: sh "/app/docker/web/entrypoint.sh"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gogobook I am curious as to what this change achieves. In command you are executing the same file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it raise an error when I using "entrypoint" way, so I changed it to command.

>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
# until psql -h "postgres_db" -U "postgres" -c '\l'; do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gogobook What is the reason for removing this ?

This makes sure that postgres is up and running before we run any migrations.

Copy link
Author

@gogobook gogobook Dec 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an error in my trying, it raise 'Postgres is unavailable - sleeping', when comment these code, it will be fine.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this and I am getting the error that postgres is not available. The Postgres check is required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Run 'docker-compose restart web'. And 'web' container will start normally. The error message is 'Is the server running on host "postgres_db" (172.19.0.3) and accepting TCP/IP connections on port 5432?', and add "sleep 3" to entrypoint.sh can solve it. The 'psql' is not exist in 'web' container.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sleep 3 doesn't solve the problem, as it assumes that postgres will be up within 3 seconds. We can't make that assumption.

If psql is not available why don't you add it to Dockerfile ?

Docker docs themselves suggest to use this method.
Check the example in this https://docs.docker.com/compose/startup-order/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need psql, we have to install postgresql to web container, and I don't like this way. If we don't like 'sleep 3', maybe the better solution is 'wait-for' script, action like the example.

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