feat(compose/api): move healthcheck to Dockerfile + update entrypoint.sh
This commit is contained in:
parent
bc71203869
commit
235c415205
|
@ -29,10 +29,6 @@ FUNKWHALE_SPA_HTML_ROOT=http://nginx/
|
|||
LDAP_ENABLED=False
|
||||
BROWSABLE_API_ENABLED=True
|
||||
|
||||
# celeryworker
|
||||
|
||||
CELERYD_CONCURRENCY=0
|
||||
|
||||
# api + nginx
|
||||
|
||||
STATIC_ROOT=/staticfiles
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Exclude everything and allow only the necessary files
|
||||
*
|
||||
!/docker/
|
||||
!/config/
|
||||
!/funkwhale_api/
|
||||
!/entrypoint.sh
|
||||
!/manage.py
|
||||
!/poetry.lock
|
||||
!/pyproject.toml
|
||||
|
|
|
@ -103,6 +103,7 @@ ARG PIP_NO_CACHE_DIR=1
|
|||
RUN set -eux; \
|
||||
apk add --no-cache \
|
||||
bash \
|
||||
curl \
|
||||
ffmpeg \
|
||||
gettext \
|
||||
jpeg-dev \
|
||||
|
@ -132,6 +133,8 @@ RUN --mount=type=cache,target=~/.cache/pip; \
|
|||
set -eux; \
|
||||
pip3 install --no-deps --editable .
|
||||
|
||||
ENV IS_DOCKER_SETUP=true
|
||||
ADD --chown=0:0 --chmod=u+x ./entrypoint.sh /
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
|
||||
CMD ["./docker/server.sh"]
|
||||
HEALTHCHECK --start-period=60s --interval=10s --timeout=5s --retries=3 \
|
||||
CMD curl -o /dev/null -s -w "%{http_code}" http://localhost:5000/api/v1 | grep "301" || exit 1
|
||||
|
|
|
@ -51,6 +51,7 @@ ENV PATH="/venv/bin:$PATH"
|
|||
RUN --mount=type=cache,target=/var/lib/apt/lists \
|
||||
apt update; \
|
||||
apt install -y \
|
||||
curl \
|
||||
ffmpeg \
|
||||
gettext \
|
||||
libjpeg-dev \
|
||||
|
@ -68,4 +69,8 @@ WORKDIR /app
|
|||
COPY . /app
|
||||
RUN poetry install --extras typesense
|
||||
|
||||
CMD ["./docker/server.sh"]
|
||||
ADD --chown=0:0 --chmod=u+x ./entrypoint.sh /
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
|
||||
HEALTHCHECK --start-period=60s --interval=10s --timeout=5s --retries=3 \
|
||||
CMD curl -o /dev/null -s -w "%{http_code}" http://localhost:5000/api/v1 | grep "301" || exit 1
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eux
|
||||
|
||||
funkwhale-manage collectstatic --noinput
|
||||
funkwhale-manage migrate
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
exec gunicorn config.asgi:application \
|
||||
--workers "${FUNKWHALE_WEB_WORKERS-1}" \
|
||||
--worker-class uvicorn.workers.UvicornWorker \
|
||||
--bind 0.0.0.0:"${FUNKWHALE_API_PORT}" \
|
||||
${GUNICORN_ARGS-}
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -eux
|
||||
|
||||
case "${1}" in
|
||||
gunicorn)
|
||||
# shellcheck disable=SC2086
|
||||
exec gunicorn config.asgi:application \
|
||||
--workers "${FUNKWHALE_WEB_WORKERS:-1}" \
|
||||
--worker-class uvicorn.workers.UvicornWorker \
|
||||
--bind 0.0.0.0:"${FUNKWHALE_API_PORT}" \
|
||||
${GUNICORN_ARGS:-}
|
||||
;;
|
||||
migrate)
|
||||
funkwhale-manage migrate
|
||||
;;
|
||||
collectstatic)
|
||||
funkwhale-manage collectstatic --noinput
|
||||
;;
|
||||
uvicorn)
|
||||
exec uvicorn \
|
||||
--reload config.asgi:application \
|
||||
--host 0.0.0.0 \
|
||||
--port 5000 \
|
||||
--reload-dir config/ \
|
||||
--reload-dir funkwhale_api/
|
||||
;;
|
||||
develop)
|
||||
${0} migrate
|
||||
${0} collectstatic
|
||||
${0} uvicorn
|
||||
;;
|
||||
develop-celery)
|
||||
export CELERYD_CONCURRENCY=0
|
||||
watchmedo auto-restart \
|
||||
--patterns="*.py" \
|
||||
--recursive \
|
||||
-- \
|
||||
celery \
|
||||
-A funkwhale_api.taskapp worker \
|
||||
-B \
|
||||
-l debug \
|
||||
-s /tmp/celerybeat-schedule \
|
||||
--concurrency=${CELERYD_CONCURRENCY}
|
||||
;;
|
||||
*)
|
||||
exec "${@}"
|
||||
;;
|
||||
esac
|
|
@ -50,22 +50,8 @@ services:
|
|||
build:
|
||||
context: ../api
|
||||
dockerfile: Dockerfile.debian
|
||||
healthcheck:
|
||||
test: 'curl -o /dev/null -s -w "%{http_code}" http://localhost:5000/api/v1 | grep "301" || exit 1'
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
command: >
|
||||
sh -c "
|
||||
funkwhale-manage collectstatic --no-input &&
|
||||
uvicorn --reload config.asgi:application --host 0.0.0.0 --port 5000 --reload-dir config/ --reload-dir funkwhale_api/
|
||||
"
|
||||
command: develop
|
||||
|
||||
celeryworker:
|
||||
<<: *django
|
||||
command: >
|
||||
sh -c '
|
||||
pip install watchdog[watchmedo] &&
|
||||
watchmedo auto-restart --patterns="*.py" --recursive -- celery -A funkwhale_api.taskapp worker -l debug -B --concurrency=${CELERYD_CONCURRENCY}
|
||||
'
|
||||
command: develop-celery
|
||||
|
|
|
@ -1,26 +1,17 @@
|
|||
FROM node:22-alpine
|
||||
FROM node:18-alpine
|
||||
|
||||
# needed to compile translations
|
||||
RUN apk add --no-cache jq bash coreutils git python3
|
||||
RUN apk add --no-cache jq bash coreutils python3
|
||||
|
||||
WORKDIR /app/
|
||||
|
||||
# Create node_modules directory to prevent it from being hidden by volume mounts
|
||||
RUN mkdir -p node_modules
|
||||
|
||||
ADD scripts/ ./scripts/
|
||||
ADD package.json yarn.lock ./
|
||||
RUN yarn
|
||||
|
||||
VOLUME /app
|
||||
VOLUME /app/node_modules
|
||||
EXPOSE 8080
|
||||
WORKDIR /app/
|
||||
COPY scripts/ ./scripts/
|
||||
ADD package.json yarn.lock ./
|
||||
RUN yarn install
|
||||
|
||||
<<<<<<< HEAD
|
||||
CMD ["yarn", "dev", "--host"]
|
||||
=======
|
||||
CMD ["yarn", "serve"]
|
||||
COPY . .
|
||||
|
||||
CMD [ "yarn", "serve" ]
|
||||
|
||||
HEALTHCHECK --start-period=30s --interval=10s --timeout=5s \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1
|
||||
>>>>>>> afceb5bf3 (chore(compose): dependencies, environments and healthchecks)
|
||||
|
|
Loading…
Reference in New Issue