From f24869ce3d009c5872d4508acba6e6a00256df92 Mon Sep 17 00:00:00 2001 From: jon r Date: Tue, 25 Feb 2025 01:09:10 +0100 Subject: [PATCH] chore(compose): dependencies, environments and healthchecks --- compose.yml | 45 ++++++++++++------------------------------ compose/app.django.yml | 18 ++++++++--------- compose/app.nginx.yml | 28 +++++++++++++++++++++----- compose/app.vue.yml | 17 ++++++++++++++++ front/Dockerfile.dev | 7 +++++++ 5 files changed, 68 insertions(+), 47 deletions(-) create mode 100644 compose/app.vue.yml diff --git a/compose.yml b/compose.yml index 1402abccf..2b5e2f9ff 100644 --- a/compose.yml +++ b/compose.yml @@ -4,26 +4,19 @@ networks: external: true x-django: &django + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy dns: 172.17.0.1 dns_search: funkwhale.test services: front: - build: - context: ./front - dockerfile: Dockerfile.dev - ports: - - "${VUE_PORT:-8080}:${VUE_PORT:-8080}" - environment: - - HOST - - VUE_PORT - volumes: - - "./front:/app" - - "/app/node_modules" - - "./po:/po" - networks: - - internal - command: "yarn dev --host" + extends: + file: ./compose/app.vue.yml + service: app api: extends: @@ -41,26 +34,14 @@ services: extends: file: ./compose/app.nginx.yml service: nginx - environment: - - "MUSIC_DIRECTORY_PATH=${MUSIC_DIRECTORY_PATH:-/music}" - - "FUNKWHALE_HOSTNAME=${COMPOSE_PROJECT_NAME:-funkwhale}.${FUNKWHALE_DOMAIN}" - - - FUNKWHALE_PROTOCOL - - - FUNKWHALE_API_HOST - - FUNKWHALE_API_PORT - - - FUNKWHALE_FRONT_IP - - FUNKWHALE_FRONT_PORT - - - NGINX_MAX_BODY_SIZE - - - STATIC_ROOT - - "MEDIA_ROOT=${MEDIA_ROOT:-/data/media}" + depends_on: + front: + condition: service_healthy + api: + condition: service_healthy networks: - web - internal - labels: - "traefik.enable=true" diff --git a/compose/app.django.yml b/compose/app.django.yml index 16360ec29..74423d1dc 100644 --- a/compose/app.django.yml +++ b/compose/app.django.yml @@ -5,11 +5,11 @@ x-django: &django volumes: - ../api:/app - ../.env:/app/.env - - '${MUSIC_DIRECTORY_SERVE_PATH:-../.state/music}:/music:ro' - - '../.state/plugins:/srv/funkwhale/plugins' - - '../.state/staticfiles:/staticfiles' - - '../.state/media:/protected/media' - - '../.state/${COMPOSE_PROJECT_NAME:-funkwhale}/media:/data/media' + - "${MUSIC_DIRECTORY_SERVE_PATH:-../.state/music}:/music:ro" + - "../.state/plugins:/srv/funkwhale/plugins" + - "../.state/staticfiles:/staticfiles" + - "../.state/media:/protected/media" + - "../.state/${COMPOSE_PROJECT_NAME:-funkwhale}/media:/data/media" depends_on: postgres: condition: service_healthy @@ -55,10 +55,11 @@ services: context: ../api dockerfile: Dockerfile.debian healthcheck: - test: ['CMD-SHELL', 'docker compose logs api | grep -q "Uvicorn running on" || exit 0'] - interval: 3s + 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 && @@ -72,6 +73,3 @@ services: pip install watchdog[watchmedo] && watchmedo auto-restart --patterns="*.py" --recursive -- celery -A funkwhale_api.taskapp worker -l debug -B --concurrency=${CELERYD_CONCURRENCY} ' - depends_on: - api: - condition: service_healthy diff --git a/compose/app.nginx.yml b/compose/app.nginx.yml index 85be2caa0..4d50c1cbe 100644 --- a/compose/app.nginx.yml +++ b/compose/app.nginx.yml @@ -1,9 +1,24 @@ services: nginx: image: nginx - depends_on: - - api - - front + networks: + - internal + environment: + - "MUSIC_DIRECTORY_PATH=${MUSIC_DIRECTORY_PATH:-/music}" + - "FUNKWHALE_HOSTNAME=${COMPOSE_PROJECT_NAME:-funkwhale}.${FUNKWHALE_DOMAIN}" + + - FUNKWHALE_PROTOCOL + + - FUNKWHALE_API_HOST + - FUNKWHALE_API_PORT + + - FUNKWHALE_FRONT_HOST + - FUNKWHALE_FRONT_PORT + + - NGINX_MAX_BODY_SIZE + + - STATIC_ROOT + - "MEDIA_ROOT=${MEDIA_ROOT:-/data/media}" volumes: - '${MUSIC_DIRECTORY_SERVE_PATH:-../.state/music}:${MUSIC_DIRECTORY_PATH:-/music}:ro' @@ -14,5 +29,8 @@ services: - ../.state/staticfiles:/usr/share/nginx/html/staticfiles:ro - ../.state/media:/protected/media:ro - ../.state/${COMPOSE_PROJECT_NAME:-funkwhale}/media:/data/media:ro - networks: - - internal + healthcheck: + test: 'curl -o /dev/null -s -w "%{http_code}" http://localhost:80/ | grep "200" || exit 1' + interval: 5s + timeout: 3s + retries: 3 diff --git a/compose/app.vue.yml b/compose/app.vue.yml new file mode 100644 index 000000000..758a0cb0c --- /dev/null +++ b/compose/app.vue.yml @@ -0,0 +1,17 @@ +services: + app: + image: funkwhale-app + build: + context: ../front + dockerfile: Dockerfile.dev + command: "yarn dev --host" + ports: + - "${VUE_PORT:-8080}:${VUE_PORT:-8080}" + networks: + - internal + volumes: + - "../front:/app" + - "/app/node_modules" + environment: + - HOST + - VUE_PORT diff --git a/front/Dockerfile.dev b/front/Dockerfile.dev index 627f7d2f9..ddd30d7f6 100644 --- a/front/Dockerfile.dev +++ b/front/Dockerfile.dev @@ -16,4 +16,11 @@ VOLUME /app VOLUME /app/node_modules EXPOSE 8080 +<<<<<<< HEAD CMD ["yarn", "dev", "--host"] +======= +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)