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 8757be4db..74423d1dc 100644 --- a/compose/app.django.yml +++ b/compose/app.django.yml @@ -55,14 +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 && @@ -76,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 86cca2bf0..6000b3491 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 f280b65ae..3605f0691 100644 --- a/front/Dockerfile.dev +++ b/front/Dockerfile.dev @@ -12,3 +12,6 @@ RUN yarn install COPY . . CMD ["yarn", "serve"] + +HEALTHCHECK --start-period=30s --interval=10s --timeout=5s \ + CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1