Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
fix(dockerfile): health check with logging issue
Browse files Browse the repository at this point in the history
Signed-off-by: hldh214 <[email protected]>
  • Loading branch information
hldh214 committed Aug 19, 2023
1 parent 286c207 commit b9e7dc8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
!Pipfile.lock
!lokbot
!config.example.json
!docker-entrypoint.sh
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ ENV PATH="/app/.venv/bin:$PATH"
HEALTHCHECK --retries=1 \
CMD if grep -q Exception /app/data/output.log; then exit 1; else exit 0; fi

ENTRYPOINT ["/bin/sh", "-c", "python -m lokbot $TOKEN $CAPTCHA_SOLVER_CONFIG 2>&1 | tee -a data/output.log"]
ENTRYPOINT ["/app/docker-entrypoint.sh"]

CMD ["/bin/sh", "-c", "python -m lokbot $TOKEN $CAPTCHA_SOLVER_CONFIG 2>&1 | tee -a /app/data/output.log"]
16 changes: 16 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

set -e

DATA_FOLDER=/app/data
OUTPUT_LOG_FILE=$DATA_FOLDER/output.log

# if the output log file exists, backup it with timestamp suffix
if [ -f "$OUTPUT_LOG_FILE" ]; then
mv $OUTPUT_LOG_FILE $OUTPUT_LOG_FILE.$(date +%Y%m%d%H%M%S)
else
mkdir -p $DATA_FOLDER
touch $OUTPUT_LOG_FILE
fi

exec "$@"

0 comments on commit b9e7dc8

Please sign in to comment.