Added health check to container.

This commit is contained in:
ArabCoders 2024-01-31 14:38:20 +03:00
parent c8b6cc39ac
commit 228d494c1a
3 changed files with 14 additions and 3 deletions

View file

@ -30,6 +30,7 @@ ENV UMASK=022
ENV YTP_CONFIG_PATH=/config
ENV YTP_TEMP_PATH=/tmp
ENV YTP_DOWNLOAD_PATH=/downloads
ENV YTP_PORT=8081
# removed ffmpeg as 6.1.0 is broken with DASH protocal downloads
COPY --from=mwader/static-ffmpeg:6.1.1 /ffmpeg /usr/bin/
@ -47,22 +48,23 @@ RUN sed -i 's/\r$//g' /entrypoint.sh && chmod +x /entrypoint.sh
COPY --chown=app:app ./app /app/app
COPY --chown=app:app --from=npm_builder /ytptube/dist /app/frontend/dist
COPY --chown=app:app --from=python_builder /app/.venv /app/.venv
COPY --chown=app:app ./healthcheck.sh /usr/local/bin/healthcheck
ENV PATH="/app/.venv/bin:$PATH"
RUN chown -R app:app /config /downloads
RUN chown -R app:app /config /downloads && chmod +x /usr/local/bin/healthcheck
VOLUME /config
VOLUME /downloads
EXPOSE 8081
# Switch to user
#
USER app
WORKDIR /tmp
HEALTHCHECK --interval=10s --timeout=20s --start-period=10s --retries=3 CMD [ "/usr/local/bin/healthcheck" ]
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/app/.venv/bin/python", "/app/app/main.py"]

View file

@ -204,6 +204,10 @@ class Main:
f'Added task to grab {task.get("name",task.get("url"))} content every [{cron_timer}].')
def addRoutes(self):
@self.routes.get(self.config.url_prefix + 'ping')
async def ping(_) -> Response:
return web.Response(text='pong')
@self.routes.post(self.config.url_prefix + 'add')
async def add(request: Request) -> Response:
post = await request.json()

5
healthcheck.sh Normal file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -eu pipefail
/usr/bin/curl -f http://localhost:${YTP_PORT:-8081}/ping