Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ services:
ports:
# Port 8001 to avoid conflict when running side-by-side with dejacode on 8000
- "8001:8001"
# Override the base healthcheck to target the dev runserver port.
healthcheck:
test: ["CMD", "wait-for-it", "--timeout=2", "localhost:8001"]
interval: 10s
timeout: 5s
retries: 48
start_period: 120s

# Volume mount keeps code in sync. Restart manually with: make restart-worker
worker:
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ services:
- workspace:/var/scancodeio/workspace/
- static:/var/scancodeio/static/
restart: always
# Without a healthcheck, "docker compose up --wait" only waits for the
# container to be running, not for migrate/collectstatic to complete, so
# commands relying on the database schema (e.g. `docker compose run web
# scanpipe ...`) can race ahead of the migrations.
healthcheck:
test: ["CMD", "wait-for-it", "--timeout=2", "localhost:8000"]
interval: 10s
timeout: 5s
retries: 48
start_period: 120s
depends_on:
db:
condition: service_healthy
Expand Down
13 changes: 13 additions & 0 deletions scanpipe/tests/test_scancodeio.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

from django.test import TestCase

import yaml

from scancodeio import ROOT_DIR
from scancodeio import extract_short_commit


Expand All @@ -32,3 +35,13 @@ def test_scancodeio_extract_short_commit(self):
self.assertEqual(extract_short_commit("v1.0.0-1-g123456"), "123456")
self.assertEqual(extract_short_commit("v2.0.0-5-abcdefg"), "abcdefg")
self.assertEqual(extract_short_commit("v1.5.0-2-ghijkl"), "hijkl")

def test_scancodeio_docker_compose_web_service_has_healthcheck(self):
# Without a healthcheck, `docker compose up --wait` only waits for the
# "web" container to be running, not for its migrate/collectstatic
# steps to complete. This lets a `docker compose run web scanpipe ...`
# command race ahead of the database migrations.
# See https://github.com/aboutcode-org/scancode.io/issues/1842
compose_file = ROOT_DIR.joinpath("docker-compose.yml")
compose_data = yaml.safe_load(compose_file.read_text())
self.assertIn("healthcheck", compose_data["services"]["web"])