Modify: HEALTHCHECK better use in docker-compose.yaml like optional

This commit is contained in:
Stepan Zhukovsky 2023-09-16 18:02:11 +09:00
parent c316104d94
commit 405d7da754
2 changed files with 7 additions and 5 deletions

View File

@ -29,8 +29,7 @@ ARG VERSION=0.1.0 \
USER_NAME=collector \ USER_NAME=collector \
USER_GROUP=collector \ USER_GROUP=collector \
APP_UID=1000 \ APP_UID=1000 \
APP_GID=1000 \ APP_GID=1000
HEALTHCHECK_PATH=api/v1/check/health/
# copy app dependences # copy app dependences
COPY --from=base /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/ COPY --from=base /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
@ -61,8 +60,5 @@ EXPOSE ${WEB_PORT}
LABEL maintainer="s.zhukovskii@ispsystem.com" LABEL maintainer="s.zhukovskii@ispsystem.com"
LABEL me.zhukovsky.logs-collector.version=v${VERSION} LABEL me.zhukovsky.logs-collector.version=v${VERSION}
# call the health check endpoint of app
HEALTHCHECK CMD curl --fail http://localhost:${WEB_PORT}/${HEALTHCHECK_PATH} || exit 1
# run app # run app
ENTRYPOINT [ "sh", "entrypoint.sh" ] ENTRYPOINT [ "sh", "entrypoint.sh" ]

View File

@ -27,6 +27,12 @@ services:
target: ${APP_DIR}/data target: ${APP_DIR}/data
env_file: env_file:
- ./.env - ./.env
healthcheck:
test: ["CMD", "curl", "-f", "http://${WEB_HOST}:${WEB_PORT}/${HEALTHCHECK_URL}"]
interval: 1m30s
timeout: 10s
retries: 3
start_period: 40s
volumes: volumes:
logs_collector_data: logs_collector_data: