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

feat(docker): healthcheck #166

Merged
merged 1 commit into from
Sep 16, 2021
Merged

Conversation

JuniorJPDJ
Copy link
Contributor

contains docker healthchecking as mentioned in #103

@JuniorJPDJ
Copy link
Contributor Author

With:

$ docker-compose ps
     Name             Command          State        Ports  
-----------------------------------------------------------
shynet_shynet_1   ./entrypoint.sh   Up (healthy)   8080/tcp

Without:

$ docker-compose ps
     Name             Command       State    Ports  
----------------------------------------------------
shynet_shynet_1   ./entrypoint.sh   Up      8080/tcp

@JuniorJPDJ JuniorJPDJ marked this pull request as ready for review August 27, 2021 15:47
Dockerfile Outdated Show resolved Hide resolved
@JuniorJPDJ
Copy link
Contributor Author

@milesmcc is anything still missing?

@milesmcc
Copy link
Owner

Pretty much looks good! Just to confirm, what's the difference between the two o/O flags (in -o /dev/null -O /dev/null)?

@JuniorJPDJ
Copy link
Contributor Author

-O,  --output-document=FILE      write documents to FILE
[..]
-o,  --output-file=FILE          log messages to FILE

Which means -O is for output file downloaded using wget and -o is for wget errors/logged messages.

@milesmcc
Copy link
Owner

Cool, thanks

@milesmcc milesmcc merged commit 0412032 into milesmcc:master Sep 16, 2021
@djerfy
Copy link
Contributor

djerfy commented Sep 30, 2021

Hi,

It's not good, my container doesn't start because healthcheck is ko:

[root] ~ # docker exec -ti shynet bash -c 'wget -o /dev/null -O /dev/null --header "Host: ${ALLOWED_HOSTS%,*}" "http://127.0.0.1:$PORT/healthz/?format=json"'; echo $?
1

With verbosity:

[root] ~ # docker exec -ti shynet bash -c 'wget --header "Host: ${ALLOWED_HOSTS%,*}" "http://127.0.0.1:$PORT/healthz/?format=json"'; echo $?
Connecting to 127.0.0.1:8080 (127.0.0.1:8080)
wget: server returned error: HTTP/1.1 400 Bad Request
1

Why the host header is important here? It's not a best idea, because ALLOWED_HOSTS are domain1.com,domain2.com,domain3.com and not compatible with RFC.

@JuniorJPDJ
Copy link
Contributor Author

JuniorJPDJ commented Sep 30, 2021

and ALLOWED_HOSTS is being cut on first colon

${ALLOWED_HOSTS%,*} on ALLOWED_HOSTS=domain1.com,domain2.com,domain3.com should evaluate to domain1.com

Without setting HOST header it wasn't working at all.

I've two domains in allowed hosts and it works for me.
Could you modify healthcheck in docker-compose to show everything more verbose?

EDIT: Yes. It's my fault. It was cut on LAST not the FIRST colon. It actually evaluates to this:

root@big-boy:~# ALLOWED_HOSTS=domain1.com,domain2.com,domain3.com
root@big-boy:~# echo ${ALLOWED_HOSTS%,*}
domain1.com,domain2.com

I've not checked with more than 2 domains. Quick fix will be send as PR in a few minutes. Sorry ;)

@JuniorJPDJ
Copy link
Contributor Author

JuniorJPDJ commented Sep 30, 2021

Should be fixed now ;)
Could you please check my new branch?

EDIT: Already merged. Check now ;)

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