@@ -8,6 +8,11 @@ services:
88 - db_data:/var/lib/postgresql/data/
99 shm_size : " 1gb"
1010 restart : always
11+ healthcheck :
12+ test : [ "CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}" ]
13+ interval : 10s
14+ timeout : 5s
15+ retries : 5
1116
1217 redis :
1318 image : docker.io/library/redis:latest
@@ -18,12 +23,45 @@ services:
1823 - redis_data:/data
1924 restart : always
2025
26+ # This service is responsible for ensuring the correct ownership of files
27+ # in the shared volumes used by the application (static and workspace).
28+ # It ensures that all files inside the `/var/scancodeio/` directory are owned
29+ # by the user and group with the UID and GID defined in the environment variables
30+ # APP_UID and APP_GID, which default to 1000 if not set.
31+ #
32+ # The service runs only once (due to "restart: no") and performs a `chown` operation
33+ # to change the ownership of the static and workspace directories, ensuring proper
34+ # file access rights for the running application containers.
35+ #
36+ # Volumes mounted:
37+ # - static: Ensures the ownership of static files in the /var/scancodeio/static directory
38+ # - media: Ensures the ownership of media files in the /var/scancodeio/workspace directory
39+ #
40+ # Notes: This service can be removed in future ScanCode.io release.
41+ chown :
42+ image : docker.io/library/alpine:latest
43+ restart : " no"
44+ command : sh -c "
45+ if [ ! -f /var/scancodeio/workspace/.chown_done ]; then
46+ chown -R ${APP_UID:-1000}:${APP_GID:-1000} /var/scancodeio/ &&
47+ touch /var/scancodeio/workspace/.chown_done;
48+ echo 'Chown applied!';
49+ else
50+ echo 'Chown already applied, skipping...';
51+ fi"
52+ env_file :
53+ - docker.env
54+ volumes :
55+ - static:/var/scancodeio/static/
56+ - workspace:/var/scancodeio/workspace/
57+
2158 web :
2259 build : .
23- command : wait-for-it --strict --timeout=60 db:5432 -- sh -c "
60+ command : sh -c "
2461 ./manage.py migrate &&
2562 ./manage.py collectstatic --no-input --verbosity 0 --clear &&
26- gunicorn scancodeio.wsgi:application --bind :8000 --timeout 600 --workers 8 ${GUNICORN_RELOAD_FLAG:-}"
63+ gunicorn scancodeio.wsgi:application --bind :8000 --timeout 600 \
64+ --workers 8 ${GUNICORN_RELOAD_FLAG:-}"
2765 env_file :
2866 - docker.env
2967 expose :
@@ -34,12 +72,17 @@ services:
3472 - workspace:/var/scancodeio/workspace/
3573 - static:/var/scancodeio/static/
3674 depends_on :
37- - db
75+ db :
76+ condition : service_healthy
77+ redis :
78+ condition : service_started
79+ chown :
80+ condition : service_completed_successfully
3881
3982 worker :
4083 build : .
4184 # Ensure that potential db migrations run first by waiting until "web" is up
42- command : wait-for-it --strict --timeout=120 web:8000 -- sh -c "
85+ command : wait-for-it --strict --timeout=600 web:8000 -- sh -c "
4386 ./manage.py rqworker --worker-class scancodeio.worker.ScanCodeIOWorker
4487 --queue-class scancodeio.worker.ScanCodeIOQueue
4588 --verbosity 1"
@@ -53,6 +96,7 @@ services:
5396 - redis
5497 - db
5598 - web
99+ - chown
56100
57101 nginx :
58102 image : docker.io/library/nginx:alpine
0 commit comments