-
-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
139 lines (129 loc) · 4.87 KB
/
docker-compose.yml
File metadata and controls
139 lines (129 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: scancodeio
services:
# This service checks the PostgreSQL data version before starting the database.
# PostgreSQL major versions store data in incompatible formats, so starting
# PostgreSQL 17 with data from PostgreSQL 13 would fail or cause corruption.
#
# The check reads the PG_VERSION file from the data volume (mounted read-only)
# and blocks startup if the data is from an older PostgreSQL version.
#
# If this check fails, run the migration script before starting the stack:
# ./migrate-pg13-to-17.sh
#
# For fresh installations (no existing data), this check passes automatically.
db-check:
image: docker.io/library/postgres:17
volumes:
- db_data:/var/lib/postgresql/data/:ro
entrypoint: [ "/bin/bash", "-c" ]
command:
- |
DATA_DIR="/var/lib/postgresql/data"
if [ ! -f "$$DATA_DIR/PG_VERSION" ]; then
echo "Fresh install detected, no upgrade needed."
exit 0
fi
OLD_VERSION=$$(cat "$$DATA_DIR/PG_VERSION")
echo "Found PostgreSQL data version: $$OLD_VERSION"
if [ "$$OLD_VERSION" -lt 17 ]; then
echo ""
echo "╔════════════════════════════════════════════════════════════════════╗"
echo "║ ERROR: PostgreSQL $$OLD_VERSION data detected, version 17 required ║"
echo "╠════════════════════════════════════════════════════════════════════╣"
echo "║ Your database volume contains data from an older PostgreSQL. ║"
echo "║ ║"
echo "║ To migrate, run: ║"
echo "║ ./migrate-pg13-to-17.sh ║"
echo "║ ║"
echo "╚════════════════════════════════════════════════════════════════════╝"
echo ""
exit 1
fi
echo "PostgreSQL version OK."
restart: "no"
db:
image: docker.io/library/postgres:17
depends_on:
db-check:
condition: service_completed_successfully
env_file:
- docker.env
volumes:
- db_data:/var/lib/postgresql/data/
shm_size: "1gb"
restart: always
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}" ]
interval: 10s
timeout: 5s
retries: 5
redis:
image: docker.io/library/redis:latest
# Enable redis data persistence using the "Append Only File" with the
# default policy of fsync every second. See https://redis.io/topics/persistence
command: redis-server --appendonly yes
volumes:
- redis_data:/data
restart: always
web:
build: .
command: sh -c "
./manage.py migrate &&
./manage.py collectstatic --no-input --verbosity 0 --clear &&
gunicorn scancodeio.wsgi:application --bind :8000 --timeout 600 \
--workers 8 ${GUNICORN_RELOAD_FLAG:-}"
env_file:
- docker.env
expose:
- 8000
volumes:
- .env:/opt/scancodeio/.env
- /etc/scancodeio/:/etc/scancodeio/
- workspace:/var/scancodeio/workspace/
- static:/var/scancodeio/static/
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
worker:
build: .
# Ensure that potential db migrations run first by waiting until "web" is up
command: wait-for-it --strict --timeout=600 web:8000 -- sh -c "
./manage.py rqworker --worker-class scancodeio.worker.ScanCodeIOWorker
--queue-class scancodeio.worker.ScanCodeIOQueue
--verbosity 1"
env_file:
- docker.env
volumes:
- .env:/opt/scancodeio/.env
- /etc/scancodeio/:/etc/scancodeio/
- workspace:/var/scancodeio/workspace/
depends_on:
- redis
- db
- web
nginx:
image: docker.io/library/nginx:alpine
ports:
- "${NGINX_PUBLISHED_HTTP_PORT:-80}:80"
- "${NGINX_PUBLISHED_HTTPS_PORT:-443}:443"
volumes:
- ./etc/nginx/conf.d/:/etc/nginx/conf.d/
- /var/www/html:/var/www/html
- static:/var/scancodeio/static/
depends_on:
- web
restart: always
clamav:
image: docker.io/clamav/clamav:latest
volumes:
- clamav_data:/var/lib/clamav
- workspace:/var/scancodeio/workspace/
restart: always
volumes:
db_data:
redis_data:
clamav_data:
static:
workspace: